You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-10-28] [$175] Unable to attach a receipt to Track Distance > Odometer expenses #104349
Version Number: 9.5.13-5 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from BrowserStack: Email or phone of affected tester (no customers): Logs:https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by:@fergimenes Slack conversation (hyperlinked to channel name): #Expensify Bugs
Action Performed:
Go to Track Distance.
Select Odometer.
Create a mileage expense using an enabled distance rate.
Open the created Odometer expense.
Attempt to add a receipt by clicking the receipt area or dragging/dropping an image onto it.
Expected Result:
The receipt should attach to the existing Odometer mileage expense, just as it does for a Manual distance expense.
Actual Result:
The receipt does not attach to the Odometer expense. Dragging/dropping or adding the receipt creates a separate scan expense instead. The receipt expense and Odometer expense cannot be merged.
Workaround:
Unknown
Platforms:
Select the officially supported platforms where the issue was reproduced:
Updated 2026-10-19: Corrected based on feedback from nyomanjyotisa.
Proposal
What is the root cause of that problem?
There are two causes:
Attach and drop fail. The receipt check in canEditFieldOfMoneyRequest (ReportUtils.ts:6143) allows only Manual distance expenses. For odometer, canEditReceipt is false.
Replace stays hidden.TransactionReceiptModalContent.tsx:191 sets isStitchedOdometerReceipt = isOdometerDistanceRequest(transaction) && !imageType. That is true for every odometer receipt, including ordinary uploads on created expenses.
What changes do you think we should make in order to solve the problem?
Base the Replace lock on where the expense is in its lifecycle, not on the receipt file. A receipt is built from odometer photos only while the expense is a draft. Once the expense is created, its receipt is a normal stored receipt.
Permission: in the RECEIPT branch of canEditFieldOfMoneyRequest, also allow isOdometerDistanceRequest(transaction). This fixes click, file picker, and drop on created expenses. Delete, Rotate, and Crop also become available, the same as for Manual distance.
Replace lock: change line 191 to isStitchedOdometerReceipt = isDraftTransaction && isOdometerDistanceRequest(transaction) && !imageType.
Tests:
ReportUtilsTest: canEditFieldOfMoneyRequest with RECEIPT returns true for a distance-odometer expense, for both edit and delete.
TransactionReceiptModalContent: Replace is hidden for an odometer draft, and shown for a created odometer expense. Cover a receipt built from two photos, one built from one photo, and an ordinary upload.
Your two concerns:
Ordinary uploads aren't misclassified. The check never reads the filename or the file itself, so the file's name can't change the result. On a created expense, every receipt gets Replace.
Single-photo receipts are covered, including existing ones. In a draft, the lock applies whether the receipt came from one photo or two. Expenses already created with a single photo are treated like any other created expense. They don't need a marker or a backfill.
Drop: no extra guard is needed. Drops on the report only target created expenses (useReceiptDrop reads COLLECTION.TRANSACTION). The confirmation page already disables drops for odometer (IOURequestStepConfirmation/index.tsx:708).
What alternative solutions did you explore? (Optional)
Tighter lock: also require photos on the draft, by adding && !!(transaction?.comment?.odometerStartImage || transaction?.comment?.odometerEndImage). Then a draft without photos keeps Replace for a receipt the user added. This is optional.
Filename prefix (my earlier update): dropped. It misclassifies files, misses single-photo receipts, and may not survive a server rename.
Stephen3453 and sijo0218 proposed the same draft-only check before this update.
Why the draft-only lock is safe
isDraftTransaction is true only in the create flow. It is set from the action route param (line 100). Routes from created expenses (TRANSACTION_RECEIPT.getRoute) never set it. Only the create-flow preview routes do.
Nothing rebuilds a created expense's receipt.
useOdometerReceiptStitcher runs only on the confirmation step and writes only to the draft, with isDraft = true (index.ts:104-125).
The lock was meant for drafts. It came from [Odometer] Image stitching, where Replace was hidden because the stitcher rebuilds the receipt from the photos during creation.
I verified this from code at d5772eb. I didn't test it in the browser.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/104349#issuecomment-6267017537) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
changed the title [-]Unable to attach a receipt to Track Distance > Odometer expenses[/-][+][$175] Unable to attach a receipt to Track Distance > Odometer expenses[/+]on Oct 19, 2026
@MelvinBot Attachment works with the permission change, but Replace remains hidden for ordinary uploads. Please distinguish photo-derived odometer receipts from ordinary uploads and cover attachment, replacement and drops.
nyomanjyotisa, Replace stays hidden because TransactionReceiptModalContent.tsx:191 marks every odometer receipt as stitched: isOdometerDistanceRequest(transaction) && !imageType. imageType is set only when the modal shows a raw start or end photo during creation. So it never tells you where the receipt came from.
What is the root cause of that problem?
There are two causes:
The receipt permission check in ReportUtils.ts:6123 only allows Manual distance expenses, so attach and drop fail for odometer. The fix you tested covers this.
Nothing records that a receipt was built from odometer photos. The photos stay on the device (Transaction.ts:138), and the created expense keeps only the readings (buildOptimisticTransaction.ts:137-142). The only marker is the filename prefix stitched_odometer (constants.ts:1). That prefix is missing when the user takes only one photo, because the receipt keeps the photo's own name (deriveOdometerReceipt.ts:28-33). No code reads the prefix today.
What changes do you think we should make in order to solve the problem?
Permission: allow isOdometerDistanceRequest in the RECEIPT branch of canEditFieldOfMoneyRequest (unchanged from my first proposal).
Mark every photo-derived receipt: give the single-photo receipt a name that starts with STITCHED_ODOMETER_FILENAME_PREFIX in deriveOdometerReceipt (single mode), the same way the stitched one is named.
Add a helper: create isOdometerPhotoReceipt(transaction) in TransactionUtils. It returns true only for odometer expenses where either:
the draft still has odometerStartImage or odometerEndImage, or
receipt.filename starts with the prefix.
A file the user uploads later has its own name (Receipt.ts:256-265), so the helper returns false for it.
Use the helper on each path:
Attach: no change needed. Attaching only happens when there's no receipt yet, so step 1 covers both the click and the file picker.
Replace: in TransactionReceiptModalContent, set isStitchedOdometerReceipt = !imageType && isOdometerPhotoReceipt(transaction). Replace then shows for ordinary uploads and stays hidden for photo-derived receipts.
Drop: in useShouldAddOrReplaceReceipt.ts, also return isPhotoReceiptLocked when the helper is true. In useReceiptDrop.ts, ignore the drop when that flag is set. Without this, the drop falls back to creating a new scan expense, which is the original bug.
Delete: keep it as is. It's how a user swaps out a photo-derived receipt on a created expense, because the photos can't be retaken after creation (IOURequestStepDistanceOdometer.tsx:690).
Tests:
Unit tests for the helper: two photos, one photo, an ordinary upload, a draft with photos, and a non-odometer expense.
A canEditFieldOfMoneyRequest case for odometer.
useShouldAddOrReplaceReceipt cases for photo-derived and ordinary receipts.
What alternative solutions did you explore? (Optional)
Server flag: store a flag like receipt.isOdometerReceipt on the server. This is the most reliable option, but it needs backend work.
Hide Replace only on drafts: use isDraftTransaction && isOdometerDistanceRequest && !imageType. This needs no classification, but it would allow replacing photo-derived receipts on created expenses.
Before implementing, check this
I couldn't confirm that the server keeps the uploaded filename in receipt.filename. Logs weren't available in this run, and a ReceiptUtils.ts comment shows stored receipts as w_<hash>.jpg.
To check, create an odometer expense with two photos. Reload, then confirm receipt.filename still starts with stitched_odometer.
If the server renames the file, the prefix only works until the server responds. In that case, use one of the alternatives above.
Next Steps for Contributor+ team: To accept:@MelvinBot implement [this](https://github.com/Expensify/App/issues/104349) to create a draft PR. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin's proposal.
src/libs/ReportUtils.ts:6123: the RECEIPT branch of canEditFieldOfMoneyRequest allows only manual distance (!isDistanceRequest || isManualDistanceRequest). For odometer, canEditReceipt is false, so the empty receipt is disabled, and useShouldAddOrReplaceReceipt.ts:38-42 returns false, so useReceiptDrop.ts:70 skips replaceReceipt and :89 starts a new SCAN expense.
TransactionReceiptModalContent.tsx:191 treats every odometer receipt as stitched (isOdometerDistanceRequest && !imageType), so Replace stays hidden even for ordinary uploads.
A photo-derived receipt can only exist in a draft. In a draft, useOdometerReceiptStitcher writes transaction.receipt from odometerStartImage/odometerEndImage and clears any other receipt (index.ts:104-125). After creation, the photos are gone: they are local-only (Transaction.ts:138).
What changes do you think we should make in order to solve the problem?
canEditFieldOfMoneyRequest: add || isOdometerDistanceRequest(transaction) to line 6123. This fixes click, file picker and drop together, and enables Delete.
TransactionReceiptModalContent.tsx:191: isStitchedOdometerReceipt = isDraftTransaction && isOdometerDistanceRequest(transaction) && !imageType. Replace stays hidden while the stitcher owns the receipt. It shows on created expenses, where the receipt is server-stored like any other. No filename prefix and no backend flag needed.
Tests: in tests/unit/ReportUtilsTest.ts, check that edit and delete for RECEIPT return true for a distance-odometer transaction. Add a UI test showing that Replace is hidden on an odometer draft and shown on a created odometer expense.
What alternative solutions did you explore? (Optional)
@MelvinBot (updated): classifies by the stitched_odometer filename. It flags the risk itself: the server may rename stored receipts (ReceiptUtils.ts:55). It also keeps Delete, so Delete then attach still swaps a "locked" receipt. That makes the lock cosmetic for three extra code paths. The draft check is exact and needs one line.
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment on the PR: N/A — existing odometer receipt-editing gap; no offending regression identified.
Link to the comment on the Issue: N/A.
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A — non-critical receipt-editing issue.
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal
Precondition:
Workspace distance rate enabled; own editable expense and two dummy receipt images.
Test:
Create an odometer expense without photos. Note its amount and start/end readings.
Click the empty receipt area and attach an image; then open it and replace it. On desktop, also replace it by drag/drop. Verify each updates the same expense without creating another scan expense.
Replace the receipt offline, reconnect and reload/relaunch. Verify the replacement persists and the amount/readings remain unchanged.
Start an odometer expense with start/end photos. Open its combined preview before creation. Verify Replace is unavailable and individual photos remain editable; cancel the draft.
Verify manual-distance receipts remain editable and map/GPS-generated receipts remain protected.
Activity
MelvinBot commentedon Oct 19, 2026
Updated 2026-10-19: Corrected based on feedback from
nyomanjyotisa.Proposal
What is the root cause of that problem?
There are two causes:
canEditFieldOfMoneyRequest(ReportUtils.ts:6143) allows only Manual distance expenses. For odometer,canEditReceiptisfalse.ReceiptEmptyStateis disabled.useShouldAddOrReplaceReceiptreturnsfalse, souseReceiptDropcreates a new scan expense instead of callingreplaceReceipt.TransactionReceiptModalContent.tsx:191setsisStitchedOdometerReceipt = isOdometerDistanceRequest(transaction) && !imageType. That is true for every odometer receipt, including ordinary uploads on created expenses.What changes do you think we should make in order to solve the problem?
Base the Replace lock on where the expense is in its lifecycle, not on the receipt file. A receipt is built from odometer photos only while the expense is a draft. Once the expense is created, its receipt is a normal stored receipt.
RECEIPTbranch ofcanEditFieldOfMoneyRequest, also allowisOdometerDistanceRequest(transaction). This fixes click, file picker, and drop on created expenses. Delete, Rotate, and Crop also become available, the same as for Manual distance.isStitchedOdometerReceipt = isDraftTransaction && isOdometerDistanceRequest(transaction) && !imageType.ReportUtilsTest:canEditFieldOfMoneyRequestwithRECEIPTreturnstruefor adistance-odometerexpense, for both edit and delete.TransactionReceiptModalContent: Replace is hidden for an odometer draft, and shown for a created odometer expense. Cover a receipt built from two photos, one built from one photo, and an ordinary upload.Your two concerns:
Drop: no extra guard is needed. Drops on the report only target created expenses (
useReceiptDropreadsCOLLECTION.TRANSACTION). The confirmation page already disables drops for odometer (IOURequestStepConfirmation/index.tsx:708).What alternative solutions did you explore? (Optional)
&& !!(transaction?.comment?.odometerStartImage || transaction?.comment?.odometerEndImage). Then a draft without photos keeps Replace for a receipt the user added. This is optional.Stephen3453andsijo0218proposed the same draft-only check before this update.Why the draft-only lock is safe
isDraftTransactionis true only in the create flow. It is set from theactionroute param (line 100). Routes from created expenses (TRANSACTION_RECEIPT.getRoute) never set it. Only the create-flow preview routes do.useOdometerReceiptStitcherruns only on the confirmation step and writes only to the draft, withisDraft = true(index.ts:104-125).IOURequestStepDistanceOdometer.tsx:690).d5772eb. I didn't test it in the browser.Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/104349#issuecomment-6267017537)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
melvin-bot commentedon Oct 19, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @nyomanjyotisa (
External)j3ffffff commentedon Oct 19, 2026
[-]Unable to attach a receipt to Track Distance > Odometer expenses[/-][+][$175] Unable to attach a receipt to Track Distance > Odometer expenses[/+]melvin-bot commentedon Oct 19, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022112156367552788811
camesenin commentedon Oct 19, 2026
melvin-bot commentedon Oct 19, 2026
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
nyomanjyotisa commentedon Oct 19, 2026
@MelvinBot Attachment works with the permission change, but Replace remains hidden for ordinary uploads. Please distinguish photo-derived odometer receipts from ordinary uploads and cover attachment, replacement and drops.
MelvinBot commentedon Oct 19, 2026
Updated proposal
nyomanjyotisa, Replace stays hidden becauseTransactionReceiptModalContent.tsx:191marks every odometer receipt as stitched:isOdometerDistanceRequest(transaction) && !imageType.imageTypeis set only when the modal shows a raw start or end photo during creation. So it never tells you where the receipt came from.What is the root cause of that problem?
There are two causes:
ReportUtils.ts:6123only allows Manual distance expenses, so attach and drop fail for odometer. The fix you tested covers this.Transaction.ts:138), and the created expense keeps only the readings (buildOptimisticTransaction.ts:137-142). The only marker is the filename prefixstitched_odometer(constants.ts:1). That prefix is missing when the user takes only one photo, because the receipt keeps the photo's own name (deriveOdometerReceipt.ts:28-33). No code reads the prefix today.What changes do you think we should make in order to solve the problem?
Permission: allow
isOdometerDistanceRequestin theRECEIPTbranch ofcanEditFieldOfMoneyRequest(unchanged from my first proposal).Mark every photo-derived receipt: give the single-photo receipt a name that starts with
STITCHED_ODOMETER_FILENAME_PREFIXinderiveOdometerReceipt(singlemode), the same way the stitched one is named.Add a helper: create
isOdometerPhotoReceipt(transaction)inTransactionUtils. It returns true only for odometer expenses where either:odometerStartImageorodometerEndImage, orreceipt.filenamestarts with the prefix.A file the user uploads later has its own name (
Receipt.ts:256-265), so the helper returns false for it.Use the helper on each path:
TransactionReceiptModalContent, setisStitchedOdometerReceipt = !imageType && isOdometerPhotoReceipt(transaction). Replace then shows for ordinary uploads and stays hidden for photo-derived receipts.useShouldAddOrReplaceReceipt.ts, also returnisPhotoReceiptLockedwhen the helper is true. InuseReceiptDrop.ts, ignore the drop when that flag is set. Without this, the drop falls back to creating a new scan expense, which is the original bug.IOURequestStepDistanceOdometer.tsx:690).Tests:
canEditFieldOfMoneyRequestcase for odometer.useShouldAddOrReplaceReceiptcases for photo-derived and ordinary receipts.What alternative solutions did you explore? (Optional)
receipt.isOdometerReceipton the server. This is the most reliable option, but it needs backend work.isDraftTransaction && isOdometerDistanceRequest && !imageType. This needs no classification, but it would allow replacing photo-derived receipts on created expenses.Before implementing, check this
I couldn't confirm that the server keeps the uploaded filename in
receipt.filename. Logs weren't available in this run, and aReceiptUtils.tscomment shows stored receipts asw_<hash>.jpg.To check, create an odometer expense with two photos. Reload, then confirm
receipt.filenamestill starts withstitched_odometer.If the server renames the file, the prefix only works until the server responds. In that case, use one of the alternatives above.
Next Steps for Contributor+ team:
To accept:
@MelvinBot implement [this](https://github.com/Expensify/App/issues/104349)to create a draft PR.To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin's proposal.
view run
Stephen3453 commentedon Oct 19, 2026
Proposal
What is the root cause of that problem?
src/libs/ReportUtils.ts:6123: theRECEIPTbranch ofcanEditFieldOfMoneyRequestallows only manual distance (!isDistanceRequest || isManualDistanceRequest). For odometer,canEditReceiptis false, so the empty receipt is disabled, anduseShouldAddOrReplaceReceipt.ts:38-42returns false, souseReceiptDrop.ts:70skipsreplaceReceiptand:89starts a new SCAN expense.TransactionReceiptModalContent.tsx:191treats every odometer receipt as stitched (isOdometerDistanceRequest && !imageType), so Replace stays hidden even for ordinary uploads.A photo-derived receipt can only exist in a draft. In a draft,
useOdometerReceiptStitcherwritestransaction.receiptfromodometerStartImage/odometerEndImageand clears any other receipt (index.ts:104-125). After creation, the photos are gone: they are local-only (Transaction.ts:138).What changes do you think we should make in order to solve the problem?
canEditFieldOfMoneyRequest: add|| isOdometerDistanceRequest(transaction)to line 6123. This fixes click, file picker and drop together, and enables Delete.TransactionReceiptModalContent.tsx:191:isStitchedOdometerReceipt = isDraftTransaction && isOdometerDistanceRequest(transaction) && !imageType. Replace stays hidden while the stitcher owns the receipt. It shows on created expenses, where the receipt is server-stored like any other. No filename prefix and no backend flag needed.tests/unit/ReportUtilsTest.ts, check that edit and delete forRECEIPTreturn true for adistance-odometertransaction. Add a UI test showing that Replace is hidden on an odometer draft and shown on a created odometer expense.What alternative solutions did you explore? (Optional)
stitched_odometerfilename. It flags the risk itself: the server may rename stored receipts (ReceiptUtils.ts:55). It also keeps Delete, so Delete then attach still swaps a "locked" receipt. That makes the lock cosmetic for three extra code paths. The draft check is exact and needs one line.18 remaining items
nyomanjyotisa commentedon Oct 22, 2026
Contributor+ Checklist:
[Contributor] The offending PR and associated issue have been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to the comment on the PR: N/A — existing odometer receipt-editing gap; no offending regression identified.
Link to the comment on the Issue: N/A.
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: N/A — non-critical receipt-editing issue.
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal
Precondition:
Test:
Do we agree 👍 or 👎
melvin-bot commentedon Oct 27, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Oct 27, 2026
Payment Summary
Resolving PRs:
Let users attach and replace receipts on created odometer expenses #104375
Reviewer: @nyomanjyotisa owed $175 via NewDot
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Oct 30, 2026
Payment Summary
Contributor+: @nyomanjyotisa due $175 via NewDot