Repository navigation
Description
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: 9.3.82-3
Reproducible in staging?: Needs Reproduction (Unable to reproduce)
Reproducible in production?: Needs Reproduction
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: @Tmjarnesk1
Slack conversation (hyperlinked to channel name): #Expensify Bugs
Action Performed:
- On web, go to Create > Track distance.
- Select Map.
- Enter start/stop locations and additional stops.
- Confirm the calculated distance and amount.
- Select Create expense.
- Open the saved expense and check the receipt panel.
Expected Result:
A map-based distance expense should generate and attach a map receipt showing the route/stops and distance details.
Actual Result:
The expense saves with the correct distance, amount, date, and category, but no map receipt is attached. The receipt panel still prompts the user to “Add a receipt” after saving.
Workaround:
Unknown
Platforms:
Select the officially supported platforms where the issue was reproduced:
- Android: App
- Android: mWeb Chrome
- iOS: App
- iOS: mWeb Safari
- iOS: mWeb Chrome
- Windows: Chrome
- MacOS: Chrome / Safari
Screenshots/Videos
The screenshot for the issue is in Slack thread
Issue Owner
Current Issue Owner: @marcochavezfMetadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
exfy-zapier commentedon May 27, 2026
This has been labelled "Needs Reproduction". Follow the steps here: https://stackoverflowteams.com/c/expensify/questions/16989
MelvinBot commentedon May 27, 2026
Proposal
What is the root cause of that problem?
When a map-based distance expense is created via Track distance, the client sets an optimistic receipt with
{source: ReceiptGeneric, state: OPEN}andpendingFields.waypoints = 'add'(TrackExpense.ts:2375). WhilependingFields.waypointsis set, the UI renders an interactiveConfirmedRoutemap (ReportActionItemImage.tsx:126-139).Once the API succeeds,
pendingFieldsare cleared (TrackExpense.ts:481) but the receipt is not updated in the success data — the real map image URL is expected to arrive separately via a Pusher push from the backend. If that Pusher update is delayed, lost, or arrives with incomplete receipt data, the transaction is left with the optimisticReceiptGenericplaceholder (a webpack asset reference, not a valid image URL). On subsequent data syncs or app reloads, the server-side transaction may not include a receipt at all, causingreceipt.stateto become falsy — which makeshasReceipt()returnfalseandshouldShowReceiptEmptyStatereturntrue, displaying "Add a receipt" instead of a map.This is likely a backend issue where the map receipt image is not being generated or persisted for certain tracked distance expenses, but there is also a client-side gap: the success data clears
pendingFields(hiding the optimisticConfirmedRoutemap) without ensuring a valid receipt URL is present.What changes do you think we should make in order to solve the problem?
Client-side improvement: In the success data for
TRACK_EXPENSEatTrackExpense.ts:476-484, preservependingFields.waypointsin the success callback so thatshowMapAsImageremainstrueand theConfirmedRoutemap continues rendering until the Pusher update arrives with the real receipt URL. Alternatively, add a condition inReportActionItemImage.tsx:126so that for map distance requests,ConfirmedRouteis also shown when the receipt source is still the generic placeholder (i.e.,!hasReceiptSource(transaction)andtransaction.comment?.waypointsexist).Backend investigation: Verify that the TRACK_EXPENSE API handler generates the map receipt image from waypoints and sends the receipt URL back via Pusher. If the backend is failing to generate or push the receipt for certain expense configurations, that is the primary fix.
What alternative solutions did you explore? (Optional)
An alternative is to keep the optimistic
ReceiptGenericreceipt with stateOPENthrough the success data and only clear it when a real receipt URL arrives via Pusher. However, this risks the receipt staying in a permanentOPENstate if the Pusher update never arrives. The preferred approach is to keep showingConfirmedRoute(which renders fromroutes.coordinatesdata, not the receipt URL) as a fallback whenever no valid receipt source exists for a map distance request.Investigation details
Symptoms extracted from issue:
Key code flow:
useExpenseSubmission.ts:610passesreceipt: undefinedfor map distance requestsTrackExpense.ts:2375creates optimistic receipt only whenvalidWaypointsis truthyTransactionUtils/index.ts:540-542sets receipt on transaction only ifreceipt.sourceis truthyTrackExpense.ts:1079usesfastMerge(existingTransactionData, optimisticTransaction)for distance requests — if the existing draft has unexpected receipt data, it could interfereTrackExpense.ts:478-484),pendingFieldsare cleared but receipt is untouched — real URL expected via PusherReportActionItemImage.tsx:126:showMapAsImagebecomesfalseoncependingFields.waypointsis clearedMoneyRequestReceiptView.tsx:275: ifreceipt.stateis falsy, shows "Add a receipt"Confidence: Medium — the client-side race condition / gap is well-evidenced, but confirming whether the backend is failing to generate the map receipt requires production log investigation.
Possibly related: Expensify/App#82997 — "Track - Map preview is not displayed when submit expense to workspace chat via self dm" (open)
Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.aswin-s commentedon May 27, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
On web, when a user creates a map-based distance expense (Create > Track distance > Map, enter waypoints, confirm, Create expense), the expense saves with the correct distance/amount but the receipt panel keeps showing the "Add a receipt" empty state instead of rendering the route map. Expected: a map distance expense should display the route/stops map in the receipt panel.
What is the root cause of that problem?
In
src/components/ReportActionItem/MoneyRequestReceiptView.tsx:275,shouldShowReceiptEmptyStateis gated only on!hasReceipt && !doesTransactionHaveReceipt. For a map distance request, the map "receipt" is server-generated and pushed later via Pusher, so the optimistic transaction built insrc/libs/TransactionUtils/index.ts:540-542(buildOptimisticTransaction) setsreceipt: undefinedbecause there is no localreceipt.source— onlyroutes(line 559) is populated. ConsequentlyhasReceipt(TransactionUtils/index.ts:571, requiresreceipt?.state) anddoesTransactionHaveReceipt(MoneyRequestReceiptView.tsx:273) are both false, so the empty state fires even though the route/map data already exists. UnlikeReportActionItemImage(which drawsConfirmedRoutefromroutes.coordinatesindependent of the receipt URL),MoneyRequestReceiptViewhas no branch that renders the route map for a map distance request when the server receipt is still pending.What changes do you think we should make in order to solve the problem?
src/components/ReportActionItem/MoneyRequestReceiptView.tsx, suppress the empty state for a pending map distance request that already has route/waypoint data: changeshouldShowReceiptEmptyState(line 275) to also require!(isMapDistanceRequest && hasRoute), computingisMapDistanceRequest(already derived at line 489) and ahasRoutecheck (mirrorMoneyRequestView.tsx:300which useshasRoute/transaction.comment.waypoints).isMapDistanceRequest && hasRoute && !hasReceipt, the panel renders the route map (ConfirmedRoutefromtransaction.routes/waypoints), mirroring the approach insrc/components/ReportActionItem/ReportActionItemImage.tsx(isMapDistanceRequest→ConfirmedRoute) rather than gating the map onhasReceipt(line 558/596).hasReceiptbecomes true) so the panel transitions from the route-map fallback to the server receipt without flicker.What alternative solutions did you explore? (Optional)
Setting an optimistic
receipt.statefor map distance requests inbuildOptimisticTransaction(line 540) was rejected: it would falsely mark the transaction as having a real receipt source and affect scan/hasReceiptSourcelogic across the app, whereas the route already exists and should drive a dedicated map render.melvin-bot commentedon May 27, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @linhvovan29546 (
External)melvin-bot commentedon May 27, 2026
Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.
yusufdeveloper2903 commentedon May 27, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a map-based Track distance expense is created on web, the saved expense keeps the correct distance, amount, date, and category, but no map receipt is attached — the receipt panel still shows the "Add receipt" empty state.
What is the root cause of that problem?
createDistanceRequestdecides whether an expense is a manual distance request from whether the validated waypoint set is empty, instead of from the transaction's request type:App/src/libs/actions/IOU/Split.ts
Lines 1918 to 1925 in 377d37b
validWaypointsisgetValidWaypoints(transaction.comment?.waypoints, true, isGPSDistanceRequest):App/src/pages/iou/request/step/confirmation/useExpenseSubmission.ts
Line 606 in 377d37b
getValidWaypointsreturns{}whenever fewer than two addressed, non‑adjacent‑duplicate waypoints survive its filter — the< 2guard and the adjacent same‑address/same‑coordinate dedup:App/src/libs/TransactionUtils/index.ts
Lines 1876 to 1907 in 377d37b
When that empty result is produced for a map distance request, the local
isManualDistanceRequestflips totrue, so two things happen together:optimisticReceiptfalls back toreceipt, which isundefinedfor a map request, sotransaction.receipt.stateis never set.waypoints: JSON.stringify(null), becausesanitizedWaypointsisnullwhenisManualDistanceRequestis true (App/src/libs/actions/IOU/Split.ts
Line 1936 in 377d37b
Distance/amount/date/category stay correct because they are read straight off the transaction, not derived from the waypoints. The empty state then appears because
hasReceiptis just!!transaction?.receipt?.state(App/src/libs/TransactionUtils/index.ts
Lines 570 to 572 in 377d37b
MoneyRequestReceiptViewshows "Add receipt" whenever!hasReceipt(App/src/components/ReportActionItem/MoneyRequestReceiptView.tsx
Line 275 in 377d37b
getValidWaypointsstrips a Map request's waypoints down to an empty set.The codebase already has the correct, type‑based notion of "manual distance request" and uses it elsewhere (e.g.
MoneyRequestReceiptViewat L489), butcreateDistanceRequestre‑derives it from the validation result instead:App/src/libs/TransactionUtils/index.ts
Lines 224 to 237 in 377d37b
What changes do you think we should make in order to solve the problem?
Decide map‑vs‑manual from the transaction's request type via the existing
isManualDistanceRequestutil, so a map distance request is never silently downgraded to manual whengetValidWaypointsreturns an empty set. The map receipt placeholder is then always attached and the (sanitized) waypoints are always sent for map requests.In
src/libs/actions/IOU/Split.ts:Add the import to the existing
@libs/TransactionUtilsblock:import { buildOptimisticTransaction, getUpdatedTransaction, isDistanceExpenseType, isDistanceRequest as isDistanceRequestTransactionUtils, + isManualDistanceRequest as isManualDistanceRequestTransactionUtils, isScanRequest as isScanRequestTransactionUtils, } from '@libs/TransactionUtils';existingTransactionis already destructured increateDistanceRequestand carriesiouRequestType(DISTANCE/DISTANCE_MAPvsDISTANCE_MANUAL), so the optimistic{source: ReceiptGeneric, state: RECEIPT_STATE.OPEN}receipt and thesanitizeWaypointsForAPI(validWaypoints)API payload are restored for map requests, while genuine manual distance requests keepreceipt/nullwaypoints unchanged.What alternative solutions did you explore? (Optional)
getValidWaypoints(e.g. relax the adjacent‑duplicate dedup or the< 2guard). Rejected — that helper also gates route validation/the API payload, so changing it risks sending degenerate routes for legitimate cases.validWaypointsis empty. Rejected — it would attach a permanently‑pendingOPENreceipt to real manual distance requests, which legitimately have no map receipt.github-actions commentedon May 27, 2026
godzillaxbox19982014-lgtm commentedon May 27, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user creates a map-based Track distance expense from global Create on web, the expense saves with the right amount/distance metadata, but the saved expense has no route/map receipt. Opening the expense receipt panel shows "Add a receipt" instead of the generated distance receipt.
Differentiator: I do not think the primary fix is only to hide the empty state in the receipt panel. The concrete failure is earlier in the TrackExpense write path: the map Track distance payload sends
waypoints/isDistance, but no uploadable receipt, and the saved transaction can come back with no receipt/eReceipt value for the panel to render.What is the root cause of that problem?
The map distance expense is going through the TrackExpense API path, but that path only creates an optimistic placeholder receipt and never sends/receives a real distance receipt.
In
src/pages/iou/request/step/confirmation/useExpenseSubmission.ts, saved distance requests only usecreateDistanceRequest()when the flow is not Track expense:For
Create > Track distance,isTrackExpenseis true, so the code falls through totrackExpense()and passes map waypoints with:Then
src/libs/actions/IOU/TrackExpense.tsbuilds a fake receipt only for optimistic UI:But the actual
TrackExpensepayload omits that receipt because the staticReceiptGenericimport is not an uploadable file on web:src/libs/isFileUploadable/index.tsonly accepts aBlobwithsize > 0, so the before-state API payload for a map Track distance expense is:isDistance=true,waypoints=<json>,receiptState=open, andreceipt=undefined. The server can save the distance/custom unit fields fromwaypoints, but the saved transaction has noreceipt.state, noreceipt.source, and nohasEReceipt.The receipt panel then follows that missing saved state. In
src/components/ReportActionItem/MoneyRequestReceiptView.tsx,hasReceiptcomes fromTransactionUtils.hasReceipt(), which is only!!transaction?.receipt?.state || hasEReceipt(transaction). With neither value present,shouldShowReceiptEmptyStatebecomes true and the panel rendersReceiptEmptyState("Add a receipt"). This is why the distance and amount are correct while the receipt panel is empty.What changes do you think we should make in order to solve the problem?
Fix the TrackExpense distance API handling so map Track distance expenses generate and return the same distance receipt/eReceipt data as the normal distance request path.
The narrow backend/API condition should be:
TrackExpenseisDistance=truewaypointsFor that case, generate/attach the route receipt from the submitted waypoints and return the saved transaction with either
receipt.state/sourceor the established eReceipt flag/data thatTransactionUtils.hasReceipt()can recognize. The App-side before/after is:TrackExpensesaveswaypointsand distance fields, but finaltransaction.receiptandtransaction.hasEReceiptare empty, so the RHP showsReceiptEmptyState.TrackExpenserequest saves the distance fields and returns a transaction with generated map receipt state/source (or eReceipt), soMoneyRequestReceiptViewrenders the route receipt instead of "Add a receipt".I would not try to upload
ReceiptGenericfrom the client. That file is intentionally just an optimistic placeholder andisFileUploadable()correctly rejects it on web; uploading it would attach a generic receipt image, not the route/stops receipt the user expects.If the team wants an App-only guard while the API work lands, the safe fallback is to render
ConfirmedRoutefor saved map-distance transactions that have route data but no receipt. That should be treated as a fallback only, because it masks the missing generated receipt rather than attaching it.What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
Create a web Track distance expense with Map waypoints from global Create, then assert the
TrackExpenserequest hasisDistance=trueand non-emptywaypoints, and after the API/Pusher update the saved transaction has a receipt/eReceipt value that makesTransactionUtils.hasReceipt()true. Opening the expense receipt panel should show the generated route receipt, notReceiptEmptyState.Also cover that manual distance and odometer Track expenses do not get a map receipt generated from empty waypoints, and normal Track expense receipt uploads still send a real uploadable file through
receipt.What alternative solutions did you explore? (Optional)
Changing the frontend to treat every map-distance transaction with route data as
hasReceiptwould hide the empty panel, but it would not attach the generated receipt to the saved expense. The API fix is narrower to the brokenTrackExpense + isDistance + waypointswrite path and preserves existing manual/odometer/receipt-upload behavior.21 remaining items
melvin-bot commentedon Jun 10, 2026
@marcochavezf @linhvovan29546 this issue was created 2 weeks ago. Are we close to a solution? Let's make sure we're treating this as a top priority. Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks!
[-]https://github.com/Expensify/App/issues/91889[/-][+] Web - No map receipt is attached[/+]mvtglobally commentedon Jun 20, 2026
Issue not reproducible during KI retests. (First week)
mvtglobally commentedon Jun 27, 2026
Issue not reproducible during KI retests. (Second week)
marcochavezf commentedon Jun 30, 2026
Catching up from OOO
mvtglobally commentedon Jul 3, 2026
Issue not reproducible during KI retests. (Third week)
mvtglobally commentedon Jul 11, 2026
Issue not reproducible during KI retests. (Fourth week)
mvtglobally commentedon Jul 17, 2026
Issue not reproducible during KI retests. (Fifth week). Closing. please reopen if needed