Repository navigation
Let users attach and replace receipts on created odometer expenses - #104375
Conversation
The receipt permission check only allowed manual distance expenses, so the receipt area on an odometer expense was disabled and a dropped file created a new scan expense. The Replace button was also hidden for every odometer receipt, though the photo-stitched receipt only exists while the expense is a draft. Co-authored-by: Nyoman Jyotisa <nyomanjyotisa@users.noreply.github.com>
|
I created this PR from an upstream branch because I couldn't find a fork of App under To take ownership of this branch and push updates, run: Then you can close this PR and open a new one from your fork. |
Co-authored-by: Nyoman Jyotisa <nyomanjyotisa@users.noreply.github.com>
|
🤖 Web test steps verification results: On dev NewDot web, the Odometer tab, expense creation, and the empty receipt area on a created Odometer expense all work. The Web test tool can't upload or drag-and-drop files, so I couldn't run the attach, Replace, or drop steps here. The earlier Android run covered attach and Replace.
|
|
@lakchote While testing this PR, I found a pre-existing accessibility issue: Changing the role to May I handle this separately under the C+ small-fix process? |
|
@lakchote I also reproduced a pre-existing receipt return-focus issue on main: after replacement, VoiceOver can remain on “Choose file” instead of returning to “View attachment.” The receipt preview and expand controls are remounted during loading. Keeping them mounted fixes the tested Safari/VoiceOver replacement and cancellation flows; cross-platform validation remains incomplete. The candidate is 14 changed lines excluding tests, or 76 including regression tests. Since the C+ small-fix guidelines require fewer than 20 lines without specifying a test exclusion, could you confirm whether it qualifies or should be tracked separately? |
|
@nyomanjyotisa Yes, go ahead with the For the return-focus one, I'd track it separately regardless of how the tests count. It changes the receipt view every expense uses, and it hasn't been checked on all platforms yet. Can you report it in #expensify-bugs with the repro on main? Neither of these blocks this PR. |
|
@MelvinBot please replace Updated testing, checklist, and recordingsTestsUse a test workspace with a distance rate and dummy images.
Offline testsReplace a cached odometer receipt offline, reconnect and reload. Verify the receipt persists on the same expense with unchanged distance and amount. QA Steps
PR Author Checklist
Screenshots/VideosAndroid: NativeAndroid-pr104375.mp4Android-pr104375-cancel-and-persistence.mp4Android: mWeb ChromeAndroid-mWeb-pr104375.mp4Android-mWeb-pr104375-persistence.mp4iOS: Nativeios-pr104375.mp4iOS: mWeb Safariios-mWeb-pr104375.mp4MacOS: Chrome / SafariChrome recording (partial) Chrome-pr104375-receipt-replacement.mp4 |
|
I replaced everything from I left out the outer |
|
@MelvinBot please mark this PR as ready for review. |
|
I marked this PR as ready for review. |
|
@nyomanjyotisa Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid-pr104375.mp4Android-pr104375-cancel-and-persistence.mp4Android: mWeb ChromeAndroid-mWeb-pr104375.mp4Android-mWeb-pr104375-persistence.mp4iOS: HybridAppios-pr104375.mp4iOS: mWeb Safariios-mWeb-pr104375.mp4MacOS: Chrome / SafariChrome-pr104375-receipt-replacement.mp4Chrome-pr104375-drag-drop.mp4 |
joekaufmanexpensify
left a comment
There was a problem hiding this comment.
good for product
lakchote
left a comment
There was a problem hiding this comment.
Looks good, a few NABs.
|
|
||
| const receiptFilename = transaction?.receipt?.filename; | ||
| const isStitchedOdometerReceipt = isOdometerDistanceRequest(transaction) && !imageType; | ||
| // Odometer photos are stitched into the receipt only while the expense is a draft, so a created expense's receipt can be replaced like any other |
There was a problem hiding this comment.
NAB: we also call open reports "Draft" in the UI, so this reads like it's about the report status. Maybe "Odometer photos are only stitched into the receipt during the create flow, so a created expense's receipt can be replaced like any other"?
| renderReceiptModal({reportID: TRANSACTION_THREAD_REPORT_ID, transactionID: TRANSACTION_ID}); | ||
| await waitForBatchedUpdatesWithAct(); | ||
|
|
||
| // Then Replace is shown, because the stitcher no longer owns the receipt once the expense is created |
There was a problem hiding this comment.
NAB: "the stitcher no longer owns the receipt" is a bit hard to parse. Maybe "because odometer photos are only stitched during the create flow"?
|
|
||
| it('should not let the submitter edit the receipt on a map distance expense', async () => { | ||
| // Given a map distance expense, whose receipt is generated from the route | ||
| const mapTransaction = createDistanceTransaction(CONST.IOU.REQUEST_TYPE.DISTANCE_MAP); |
There was a problem hiding this comment.
NAB: the description says GPS stays locked too, could we add a GPS case next to the map one? An it.each over DISTANCE_MAP and DISTANCE_GPS would cover it.
|
🚧 lakchote has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/lakchote in version: 9.5.15-1 🚀
|
|
No help site update is needed. This is a bug fix: it lets the existing receipt actions work on created odometer expenses, as users would expect, and no article says they can't. |
|
🚀 Deployed to production by https://github.com/grgia in version: 9.5.15-3 🚀
Bundle Size Analysis (Sentry): |














Explanation of Change
Users couldn't add a receipt to a created odometer expense. Clicking the receipt area did nothing, and dropping a file created a separate scan expense. Once a receipt was on the expense, Replace was also hidden.
This PR makes two changes:
canEditFieldOfMoneyRequest(theRECEIPTbranch inReportUtils.ts) allowed only manual distance expenses, socanEditReceiptwasfalsefor odometer. That disabledReceiptEmptyState, anduseShouldAddOrReplaceReceiptreturnedfalse, souseReceiptDropfell back to creating a new scan expense. The check now also allowsisOdometerDistanceRequest. This fixes the click, file picker, and drop paths, and enables Delete, Rotate, and Crop the same way they work for manual distance. Map and GPS distance expenses stay locked.TransactionReceiptModalContenttreated every odometer receipt as stitched (isOdometerDistanceRequest && !imageType), so Replace was hidden even on created expenses. The stitcher only builds the receipt from the odometer photos while the expense is a draft. The lock now also requiresisDraftTransaction. Replace stays hidden in the create flow and shows on created expenses. This doesn't depend on the filename, so ordinary uploads and receipts built from one photo are handled the same way.Tests:
canEditFieldOfMoneyRequestTest: receipt edit and delete are allowed for odometer, edit is allowed for manual distance, and edit is still blocked for map distance.TransactionReceiptOdometerReplaceTest: Replace shows for a created odometer expense and stays hidden for an odometer draft.Fixed Issues
$ #104349
PROPOSAL: #104349 (comment)
Tests
Use a test workspace with a distance rate and dummy images.
Offline tests
Replace a cached odometer receipt offline, reconnect and reload. Verify the receipt persists on the same expense with unchanged distance and amount.
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)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.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-pr104375.mp4
Android-pr104375-cancel-and-persistence.mp4
Android: mWeb Chrome
Android-mWeb-pr104375.mp4
Android-mWeb-pr104375-persistence.mp4
iOS: Native
ios-pr104375.mp4
iOS: mWeb Safari
ios-mWeb-pr104375.mp4
MacOS: Chrome / Safari
Chrome recording (partial)
Chrome-pr104375-receipt-replacement.mp4