Skip to content

Web - No map receipt is attached #91891

Closed

Description

@m-natarajan

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:

  1. On web, go to Create > Track distance.
  2. Select Map.
  3. Enter start/stop locations and additional stops.
  4. Confirm the calculated distance and amount.
  5. Select Create expense.
  6. 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

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @marcochavezf

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on May 27, 2026
  2. exfy-zapier commented on May 27, 2026

    @exfy-zapier

    This has been labelled "Needs Reproduction". Follow the steps here: https://stackoverflowteams.com/c/expensify/questions/16989

  3. MelvinBot commented on May 27, 2026

    @MelvinBot
    Contributor

    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} and pendingFields.waypoints = 'add' (TrackExpense.ts:2375). While pendingFields.waypoints is set, the UI renders an interactive ConfirmedRoute map (ReportActionItemImage.tsx:126-139).

    Once the API succeeds, pendingFields are 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 optimistic ReceiptGeneric placeholder (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, causing receipt.state to become falsy — which makes hasReceipt() return false and shouldShowReceiptEmptyState return true, 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 optimistic ConfirmedRoute map) 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_EXPENSE at TrackExpense.ts:476-484, preserve pendingFields.waypoints in the success callback so that showMapAsImage remains true and the ConfirmedRoute map continues rendering until the Pusher update arrives with the real receipt URL. Alternatively, add a condition in ReportActionItemImage.tsx:126 so that for map distance requests, ConfirmedRoute is also shown when the receipt source is still the generic placeholder (i.e., !hasReceiptSource(transaction) and transaction.comment?.waypoints exist).

    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 ReceiptGeneric receipt with state OPEN through the success data and only clear it when a real receipt URL arrives via Pusher. However, this risks the receipt staying in a permanent OPEN state if the Pusher update never arrives. The preferred approach is to keep showing ConfirmedRoute (which renders from routes.coordinates data, not the receipt URL) as a fallback whenever no valid receipt source exists for a map distance request.

    Investigation details

    Symptoms extracted from issue:

    • Track distance expense on web saves with correct distance, amount, date, category
    • No map receipt attached after saving
    • Receipt panel shows "Add a receipt"
    • Reported on Windows Chrome and macOS Chrome/Safari

    Key code flow:

    1. useExpenseSubmission.ts:610 passes receipt: undefined for map distance requests
    2. TrackExpense.ts:2375 creates optimistic receipt only when validWaypoints is truthy
    3. TransactionUtils/index.ts:540-542 sets receipt on transaction only if receipt.source is truthy
    4. TrackExpense.ts:1079 uses fastMerge(existingTransactionData, optimisticTransaction) for distance requests — if the existing draft has unexpected receipt data, it could interfere
    5. On API success (TrackExpense.ts:478-484), pendingFields are cleared but receipt is untouched — real URL expected via Pusher
    6. ReportActionItemImage.tsx:126: showMapAsImage becomes false once pendingFields.waypoints is cleared
    7. MoneyRequestReceiptView.tsx:275: if receipt.state is 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 this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on May 27, 2026
  5. aswin-s commented on May 27, 2026

    @aswin-s
    Contributor

    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, shouldShowReceiptEmptyState is 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 in src/libs/TransactionUtils/index.ts:540-542 (buildOptimisticTransaction) sets receipt: undefined because there is no local receipt.source — only routes (line 559) is populated. Consequently hasReceipt (TransactionUtils/index.ts:571, requires receipt?.state) and doesTransactionHaveReceipt (MoneyRequestReceiptView.tsx:273) are both false, so the empty state fires even though the route/map data already exists. Unlike ReportActionItemImage (which draws ConfirmedRoute from routes.coordinates independent of the receipt URL), MoneyRequestReceiptView has 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?

    1. In src/components/ReportActionItem/MoneyRequestReceiptView.tsx, suppress the empty state for a pending map distance request that already has route/waypoint data: change shouldShowReceiptEmptyState (line 275) to also require !(isMapDistanceRequest && hasRoute), computing isMapDistanceRequest (already derived at line 489) and a hasRoute check (mirror MoneyRequestView.tsx:300 which uses hasRoute/transaction.comment.waypoints).
    2. Add a render branch so that when isMapDistanceRequest && hasRoute && !hasReceipt, the panel renders the route map (ConfirmedRoute from transaction.routes/waypoints), mirroring the approach in src/components/ReportActionItem/ReportActionItemImage.tsx (isMapDistanceRequest → ConfirmedRoute) rather than gating the map on hasReceipt (line 558/596).
    3. Verify the same condition is correct once the Pusher-pushed receipt arrives (hasReceipt becomes 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.state for map distance requests in buildOptimisticTransaction (line 540) was rejected: it would falsely mark the transaction as having a real receipt source and affect scan/hasReceiptSource logic across the app, whereas the route already exists and should drive a dedicated map render.

  6. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on May 27, 2026
  7. melvin-bot commented on May 27, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @linhvovan29546 (External)

  8. melvin-bot commented on May 27, 2026

    @melvin-bot

    Unable to auto-create job on Upwork. The BZ team member should create it manually for this issue.

  9. yusufdeveloper2903 commented on May 27, 2026

    @yusufdeveloper2903
    Contributor

    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?

    createDistanceRequest decides whether an expense is a manual distance request from whether the validated waypoint set is empty, instead of from the transaction's request type:

    const isManualDistanceRequest = isEmptyObject(validWaypoints);

    const isManualDistanceRequest = isEmptyObject(validWaypoints);
    const optimisticReceipt: Receipt | undefined = !isManualDistanceRequest
    ? {
    source: ReceiptGeneric as ReceiptSource,
    state: CONST.IOU.RECEIPT_STATE.OPEN,
    }
    : receipt;

    validWaypoints is getValidWaypoints(transaction.comment?.waypoints, true, isGPSDistanceRequest):

    validWaypoints: getValidWaypoints(transaction.comment?.waypoints, true, isGPSDistanceRequest),

    getValidWaypoints returns {} whenever fewer than two addressed, non‑adjacent‑duplicate waypoints survive its filter — the < 2 guard and the adjacent same‑address/same‑coordinate dedup:

    if (waypointValues.length < 2 || waypointValues.length > 25) {
    return {};
    }
    let lastWaypointIndex = -1;
    let waypointIndex = -1;
    return waypointValues.reduce<WaypointCollection>((acc, currentWaypoint, index) => {
    // Array.at(-1) returns the last element of the array
    // If a user does a round trip, the last waypoint will be the same as the first waypoint
    // We want to avoid comparing them as this will result in an incorrect duplicate waypoint error.
    const previousWaypoint = lastWaypointIndex !== -1 ? waypointValues.at(lastWaypointIndex) : undefined;
    // Check if the waypoint has a valid address
    if (!waypointHasValidAddress(currentWaypoint)) {
    return acc;
    }
    // Exclude null island
    if (isWaypointNullIsland(currentWaypoint)) {
    return acc;
    }
    // Check for adjacent waypoints with the same address or coordinate
    const previousCoordinate: Coordinate | undefined = previousWaypoint?.lng && previousWaypoint?.lat ? [previousWaypoint.lng, previousWaypoint.lat] : undefined;
    const currentCoordinate: Coordinate | undefined = currentWaypoint.lng && currentWaypoint.lat ? [currentWaypoint.lng, currentWaypoint.lat] : undefined;
    if (
    previousWaypoint &&
    (currentWaypoint?.address === previousWaypoint.address || (previousCoordinate && currentCoordinate && utils.areSameCoordinate(previousCoordinate, currentCoordinate)))
    ) {
    return acc;
    }

    When that empty result is produced for a map distance request, the local isManualDistanceRequest flips to true, so two things happen together:

    • No optimistic map receipt is attached — optimisticReceipt falls back to receipt, which is undefined for a map request, so transaction.receipt.state is never set.
    • The API is called with waypoints: JSON.stringify(null), because sanitizedWaypoints is null when isManualDistanceRequest is true (
      const sanitizedWaypoints = !isManualDistanceRequest ? sanitizeWaypointsForAPI(validWaypoints) : null;
      ), so the backend treats it as a manual distance entry and never generates the map receipt.

    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 hasReceipt is just !!transaction?.receipt?.state (

    function hasReceipt(transaction: OnyxInputOrEntry<Transaction> | undefined): boolean {
    return !!transaction?.receipt?.state || hasEReceipt(transaction);
    }
    ), and MoneyRequestReceiptView shows "Add receipt" whenever !hasReceipt (
    const shouldShowReceiptEmptyState = (isDisplayedInWideRHP || !isInvoice) && !hasReceipt && !!transactionToCheck && !doesTransactionHaveReceipt;
    ). The bug is intermittent ("unable to reproduce") precisely because it only triggers when getValidWaypoints strips 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. MoneyRequestReceiptView at L489), but createDistanceRequest re‑derives it from the validation result instead:

    function isManualDistanceRequest(transaction: OnyxEntry<Transaction>, isUpdatedMergeTransaction = false): boolean {
    // This is used during the expense creation flow before the transaction has been saved to the server
    if (transaction && Object.hasOwn(transaction, 'iouRequestType') && !isUpdatedMergeTransaction) {
    return transaction?.iouRequestType === CONST.IOU.REQUEST_TYPE.DISTANCE_MANUAL;
    }
    // This is the case for transaction objects once they have been saved to the server
    // Exclude odometer requests which also have no waypoints but have odometer readings
    return (
    hasDistanceCustomUnit(transaction) &&
    isEmptyObject(transaction?.comment?.waypoints) &&
    transaction?.comment?.odometerStart === undefined &&
    transaction?.comment?.odometerEnd === undefined
    );

    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 isManualDistanceRequest util, so a map distance request is never silently downgraded to manual when getValidWaypoints returns 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:

    - const isManualDistanceRequest = isEmptyObject(validWaypoints);
    + const isManualDistanceRequest = isManualDistanceRequestTransactionUtils(existingTransaction);

    Add the import to the existing @libs/TransactionUtils block:

      import {
          buildOptimisticTransaction,
          getUpdatedTransaction,
          isDistanceExpenseType,
          isDistanceRequest as isDistanceRequestTransactionUtils,
    +     isManualDistanceRequest as isManualDistanceRequestTransactionUtils,
          isScanRequest as isScanRequestTransactionUtils,
      } from '@libs/TransactionUtils';

    existingTransaction is already destructured in createDistanceRequest and carries iouRequestType (DISTANCE/DISTANCE_MAP vs DISTANCE_MANUAL), so the optimistic {source: ReceiptGeneric, state: RECEIPT_STATE.OPEN} receipt and the sanitizeWaypointsForAPI(validWaypoints) API payload are restored for map requests, while genuine manual distance requests keep receipt/null waypoints unchanged.

    What alternative solutions did you explore? (Optional)

    • Loosen getValidWaypoints (e.g. relax the adjacent‑duplicate dedup or the < 2 guard). Rejected — that helper also gates route validation/the API payload, so changing it risks sending degenerate routes for legitimate cases.
    • Always attach a receipt when validWaypoints is empty. Rejected — it would attach a permanently‑pending OPEN receipt to real manual distance requests, which legitimately have no map receipt.
    • Block submission and surface an error when a map request has zero valid waypoints. Rejected as the primary fix — QA reports the expense otherwise saves correctly, so type‑based classification preserves the working path rather than introducing a blocking error.
  10. github-actions commented on May 27, 2026

    @github-actions
    Contributor

    ⚠️ @yusufdeveloper2903 Thanks for your proposal. Please update it to follow the proposal template, as proposals are only reviewed if they follow that format (note the mandatory sections).

  11. godzillaxbox19982014-lgtm commented on May 27, 2026

    @godzillaxbox19982014-lgtm

    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 use createDistanceRequest() when the flow is not Track expense:

    if (!isTrackExpense && isDistanceRequest && !isMovingTransactionFromTrackExpense && !isUnreported) {
        createDistanceRequest(...);
        return;
    }

    For Create > Track distance, isTrackExpense is true, so the code falls through to trackExpense() and passes map waypoints with:

    validWaypoints: Object.keys(item?.comment?.waypoints ?? {}).length
        ? getValidWaypoints(item.comment?.waypoints, true, isGPSDistanceRequest)
        : undefined,

    Then src/libs/actions/IOU/TrackExpense.ts builds a fake receipt only for optimistic UI:

    const trackedReceipt = validWaypoints
        ? {source: ReceiptGeneric as ReceiptSource, state: CONST.IOU.RECEIPT_STATE.OPEN, name: 'receipt-generic.png'}
        : receipt;

    But the actual TrackExpense payload omits that receipt because the static ReceiptGeneric import is not an uploadable file on web:

    receipt: isFileUploadable(trackedReceipt) ? trackedReceipt : undefined,
    receiptState: trackedReceipt?.state,
    waypoints: sanitizedWaypoints,
    isDistance: isGPSDistanceRequest || isMapDistanceRequest(transaction) || ...

    src/libs/isFileUploadable/index.ts only accepts a Blob with size > 0, so the before-state API payload for a map Track distance expense is: isDistance=true, waypoints=<json>, receiptState=open, and receipt=undefined. The server can save the distance/custom unit fields from waypoints, but the saved transaction has no receipt.state, no receipt.source, and no hasEReceipt.

    The receipt panel then follows that missing saved state. In src/components/ReportActionItem/MoneyRequestReceiptView.tsx, hasReceipt comes from TransactionUtils.hasReceipt(), which is only !!transaction?.receipt?.state || hasEReceipt(transaction). With neither value present, shouldShowReceiptEmptyState becomes true and the panel renders ReceiptEmptyState ("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:

    • command: TrackExpense
    • fields: isDistance=true
    • non-empty waypoints
    • not manual distance and not odometer

    For that case, generate/attach the route receipt from the submitted waypoints and return the saved transaction with either receipt.state/source or the established eReceipt flag/data that TransactionUtils.hasReceipt() can recognize. The App-side before/after is:

    • Before: TrackExpense saves waypoints and distance fields, but final transaction.receipt and transaction.hasEReceipt are empty, so the RHP shows ReceiptEmptyState.
    • After: the same TrackExpense request saves the distance fields and returns a transaction with generated map receipt state/source (or eReceipt), so MoneyRequestReceiptView renders the route receipt instead of "Add a receipt".

    I would not try to upload ReceiptGeneric from the client. That file is intentionally just an optimistic placeholder and isFileUploadable() 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 ConfirmedRoute for 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 TrackExpense request has isDistance=true and non-empty waypoints, and after the API/Pusher update the saved transaction has a receipt/eReceipt value that makes TransactionUtils.hasReceipt() true. Opening the expense receipt panel should show the generated route receipt, not ReceiptEmptyState.

    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 hasReceipt would hide the empty panel, but it would not attach the generated receipt to the saved expense. The API fix is narrower to the broken TrackExpense + isDistance + waypoints write path and preserves existing manual/odometer/receipt-upload behavior.

  12. 21 remaining items

  13. added
    retest-weeklyApply this label if you want this issue tested on a Weekly basis by Applause
    and removed on Jun 8, 2026
  14. melvin-bot commented on Jun 10, 2026

    @melvin-bot

    @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!

  15. changed the title [-]https://github.com/Expensify/App/issues/91889[/-] [+] Web - No map receipt is attached[/+] on Jun 13, 2026
  16. mvtglobally commented on Jun 20, 2026

    @mvtglobally

    Issue not reproducible during KI retests. (First week)

  17. mvtglobally commented on Jun 27, 2026

    @mvtglobally

    Issue not reproducible during KI retests. (Second week)

  18. marcochavezf commented on Jun 30, 2026

    @marcochavezf
    Contributor

    Catching up from OOO

  19. mvtglobally commented on Jul 3, 2026

    @mvtglobally

    Issue not reproducible during KI retests. (Third week)

  20. mvtglobally commented on Jul 11, 2026

    @mvtglobally

    Issue not reproducible during KI retests. (Fourth week)

  21. mvtglobally commented on Jul 17, 2026

    @mvtglobally

    Issue not reproducible during KI retests. (Fifth week). Closing. please reopen if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugSomething is broken. Auto assigns a BugZero manager.InternalRequires API changes or must be handled by Expensify staffMonthlyKSv2Needs ReproductionReproducible steps neededretest-weeklyApply this label if you want this issue tested on a Weekly basis by Applause

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions