Preserve local image source on expense creation#86512
Preserve local image source on expense creation#86512marcaaron merged 3 commits intoExpensify:mainfrom
Conversation
|
Before before.movAfter after.mov |
src/libs/actions/IOU/index.ts
Outdated
| onyxMethod: Onyx.METHOD.SET, | ||
| key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transaction.transactionID}`, | ||
| value: transaction, | ||
| value: shouldPreserveLocalReceiptSource ? {...transaction, receipt: {...transaction.receipt, localSource: String(transaction.receipt?.source)}} : transaction, |
There was a problem hiding this comment.
❌ CONSISTENCY-3 (docs)
The expression shouldPreserveLocalReceiptSource ? {...transaction, receipt: {...transaction.receipt, localSource: String(transaction.receipt?.source)}} : transaction is duplicated verbatim here and in buildOnyxDataForMoneyRequest (line 1984). Both occurrences perform the same conditional augmentation of the transaction with a localSource field.
Extract a small helper function to eliminate the duplication:
function getTransactionWithPreservedLocalReceiptSource(transaction: OnyxTypes.Transaction, isScanRequest: boolean): OnyxTypes.Transaction {
if (isScanRequest && isLocalFile(transaction.receipt?.source)) {
return {...transaction, receipt: {...transaction.receipt, localSource: String(transaction.receipt?.source)}};
}
return transaction;
}Then both call sites simplify to:
value: getTransactionWithPreservedLocalReceiptSource(transaction, isScanRequest),Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
marcaaron
left a comment
There was a problem hiding this comment.
Changes LGTM! Nice improvement 🙇
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
joekaufmanexpensify
left a comment
There was a problem hiding this comment.
Good from a product perspective
|
I don't think Reassure tests are related so going to merge this one! |
|
🚧 @marcaaron has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/marcaaron in version: 9.3.52-0 🚀
Bundle Size Analysis (Sentry): |
|
I reviewed all changes in this PR. The modifications are:
Conclusion: No help site changes are required. This is an internal bug fix that prevents receipt images from flickering when the server response replaces the local file URI. It does not introduce, rename, or modify any user-facing features, settings, buttons, or workflows. The existing help site articles about expenses and SmartScan remain accurate as-is. |
Explanation of Change
Problem: when user create an expense with receipt its local source (
file://) is replaced by server createdsourcevalue and due to this application tries to download image from server - although it's already available locally.To handle this we preserve the local source in
localSourceand render the image like thislocalSource ?? sourceso if there is local image it takes precedence and user does not need to wait for the image.Fixed Issues
$ #85875
PROPOSAL:
Tests
Offline tests
N/A. Solution needs internet connection as bug is related to server's overwriting local image.
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
after.mov