Report - Map disappears everytime user goes offline after changing expense rate.
If you havenβt already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: 9.4.52-2 Reproducible in staging?: Yes Reproducible in production?: No If this was caught during regression testing, add the test name, ID and link from BrowserStack: https://github.com/Expensify/App/pull/97517 Email or phone of affected tester (no customers): [email protected] Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Motorola MotoG60 / Android 12 (Hybrid app) - Windows 11 / Chrome App Component: Money Requests
Action Performed:
- Open a workspace chat, tap + β Track distance, set a start and stop, and submit.
- Wait for the map to appear on the expense preview in the chat.
- Go offline.
- Open the expense, tap Rate, change the rate.
- Go back to the chat.
Expected Result:
The map stays on the expense preview.
Actual Result:
The map is replaced by the grey pending-map placeholder until you go back online.
Workaround:
Unknown
Platforms:
- [x] Android: App
- [ ] Android: mWeb Chrome
- [ ] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [ ] MacOS: Chrome Safari
Screenshots/Videos
https://github.com/user-attachments/assets/7d60c2ae-f4a2-4756-9b2e-c203487eef42
Applause Internal Information Exported by: Svetlana Lazutkina Bug ID: 7231186
Issue Owner
Current Issue Owner: @samranahm
While Applause doesn't embed attachments for this bug, here are the links for quick view: https://platform.applause.com/services/links/v1/external/60d7ddec94679c380bd8f4e48c42fe10ce49ecb7203fb4781cc11a073f3cc877
You have been assigned to this deploy blocker because you recently merged this PR: https://github.com/Expensify/App/pull/97517
@Valforte @abdulrahuman5196 you have been assigned to this deploy blocker because you reviewed the offending PR: https://github.com/Expensify/App/pull/97517
@Gonals you have been assigned to this deploy blocker because you authored the offending PR: https://github.com/Expensify/App/pull/97517
π¬ A slack conversation has been started in #expensify-open-source
:wave: Friendly reminder that deploy blockers are time-sensitive β± issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
- Identify the pull request that introduced this issue and revert it.
- Find someone who can quickly fix the issue.
- Fix the issue yourself.
Issue Analysis β Deploy Blocker #98364
TL;DR: Do not blind-revert #97517. Its changes are gated on isFetchingWaypointsFromServer, which is false in this repro (a rate edit never sets pendingFields.waypoints), so the code it touched doesn't execute in this flow. The offline behavior here looks largely pre-existing: the map preview is a remote Mapbox image that can't load offline, and the local offline fallback only stays active while an edit is still pending β not in the steady state this repro ends in. Verdict: NEEDS INVESTIGATION (needs a runtime bisect), and this is a strong DEMOTE candidate (visual only, fully recovers online, requires an uncommon delete-rate β edit-rate β offline sequence, no data loss, and not reproducible in production).
Why #97517 is very unlikely to be the cause: all three of its logic changes only alter behavior when isFetchingWaypointsFromServer(transaction) is true:
- Recompute gate β
TransactionUtils/index.ts:765(added|| hasLocallyKnownDistance(...)) - New helper
hasLocallyKnownDistanceL1188-1190 - Optimistic
MODIFIED_EXPENSEgate βUpdateMoneyRequest.ts:1725
isFetchingWaypointsFromServer is just !!transaction?.pendingFields?.waypoints (L1177-1178). In this repro the expense is fully created (map already generated) and only the rate is edited β which never touches pendingFields.waypoints β so all three branches evaluate identically before and after the PR. The bug is also repeatable (map vanishes every time offline, returns every time online), i.e. a persistent steady state with no pending fields β precisely where #97517's changes are inert.
Likely mechanism (root cause): In the chat expense preview the map is a remote Mapbox image (.../<source>.320.jpg, isAuthTokenRequired: true), so offline it can't be fetched and falls back to a generic receipt icon β "map disappears." The only thing that keeps it visible offline is showMapAsImage in ReportActionItemImage.tsx:144, which draws the local ConfirmedRoute β but that path is active only while hasErrors || hasPendingDistanceReceiptRegeneration(transaction) is true (edit still pending). Once the rate edit has synced (the steady state here), that flag is false and the preview depends on the network. That fallback logic shipped to production in early July (e.g. #95563), so it isn't the staging-only regression either.
Recommended next step: A runtime bisect is needed to confirm the trigger. Two quick checks:
- Reproduce steps 1-11, then inspect the transaction Onyx object when the map disappears:
pendingFields,amount,comment.customUnit.quantity,routes.route0,receipt.source. - Check whether a plain distance expense (no rate edit) also loses its preview map offline. If yes β largely pre-existing, demote. If only the edited-rate case regresses β bisect the distance/receipt-preview PRs in the #98179 checklist (note: #97313 reworks receipt image-source selection in this same file but merged after the checklist was cut, so it's not in the tested 9.4.52-2 build).
Investigation details & notes
- Attempted runtime verification (check #2 above) on web but the test session rendered a blank page, so I couldn't confirm live β the analysis above is code-level only.
- The deleted-original-rate fallback path lives at
TransactionUtils/index.ts:772-787and is pre-existing (not from #97517) β worth inspecting during the bisect. - Remote image load path:
ReportActionItemImage.tsx:190-217; thumbnail URL construction:ReceiptUtils.ts:73-79.
Confidence: Frontend/App bug (keep DeployBlockerCash): High. #97517 is not the cause: Medium-High. Exact causing PR / definitive root cause: Low (needs the runtime bisect above).
Next Steps for Contributor+ team:
To refine: @MelvinBot <your feedback>
To reject: Explain why you're rejecting this analysis.
I'm going to say this one is not a blocker
Assigning @aimane-chnaif to validate Melvin analysis before opening to externals
I reproduced this in production. We can treat this as regular bug. @MelvinBot submit proposal
https://github.com/user-attachments/assets/1e2cf533-3bea-4518-8554-b6244226315e
Proposal
Thanks for reproducing in prod, aimane-chnaif. Here's a proposal. My earlier "largely pre-existing / likely not #97517" read was wrong on the mechanism β the offline blank comes from the showMapAsImage β ConfirmedRoute path, not from a remote image failing to load.
What is the root cause of that problem?
The expense-preview map is normally the remote Mapbox thumbnail (receipt.source), which stays visible offline because it was cached while online. But ReportActionItemImage swaps that thumbnail for a locally-drawn <ConfirmedRoute> whenever showMapAsImage is true:
showMapAsImage = isMapDistanceRequest && (hasErrors || hasPendingDistanceReceiptRegeneration(transaction))
The catch: ConfirmedRoute cannot render a Mapbox map offline β when isOffline it falls back to a blank PendingMapView placeholder. So any time showMapAsImage is true and you're offline, the map area goes blank.
In this repro the transaction is left persistently dirty after the edit β a pendingFields entry (customUnitRateID/merchant) that doesn't clear and/or a lingering errorFields β so showMapAsImage stays true in the steady state (not just during the brief regeneration it was designed for). The preview is stuck on ConfirmedRoute, which shows the real map online (DistanceMapView) but a blank placeholder every time you go offline β exactly the "disappears offline, reappears online, repeatably" signature. A plain distance expense keeps showMapAsImage false, stays on the cached thumbnail, and therefore survives offline.
Why the "delete the used rate" prerequisite matters: editing a rate whose original no longer exists on the policy leaves the modified-expense in a pending/error state that never resolves cleanly, which is what keeps showMapAsImage stuck true.
Evidence & the one runtime check that pins the exact stuck field
- Gate:
ReportActionItemImage.tsx:142-144βshowMapAsImagetrue β renders<ConfirmedRoute>at L158-171; false β remote thumbnail branch (isAuthTokenRequired: true) at L190-201. - Offline blank:
ConfirmedRoute.tsx:87gates the real map on!isOffline, elsePendingMapView(grey icon). - Regeneration flag:
hasPendingDistanceReceiptRegenerationis true while any ofwaypoints/distance/merchant/customUnitRateIDis pending; a rate edit setscustomUnitRateID+merchantinUpdateMoneyRequest.ts. - Distance receipts never carry a local blob β steady state always points at the remote
${source}.1024.jpg(ReceiptUtils.ts:73-79), so the only offline-safe render for a synced distance expense is the cached thumbnail.
Runtime check to confirm which input stays true: reproduce steps 1-9, and right after the edit lands (before going offline) inspect the transaction Onyx object for pendingFields.customUnitRateID / pendingFields.merchant, errors, and errorFields.route/errorFields.waypoints. Whichever is non-empty is what holds showMapAsImage true.
What changes do you think we should make in order to solve the problem?
Primary (fixes the symptom robustly): stop routing to ConfirmedRoute when we're offline and a cached receipt thumbnail exists. Offline, ConfirmedRoute can only render a blank placeholder, so the cached remote thumbnail is strictly better. In ReportActionItemImage, add an offline guard to the gate so that when isOffline (from useNetwork) and hasReceiptSource(transaction) is true, we fall through to the thumbnail branch instead of ConfirmedRoute. This preserves the intended online behavior (draw the live route while the receipt URL is regenerating) and keeps the map visible offline.
Complementary (addresses the deeper cause): ensure the pending/error state actually clears after editing a rate whose original rate was deleted, so the transaction returns to steady state (showMapAsImage false) even while online. This depends on which field stays set β see the runtime check above.
What alternative solutions did you explore? (Optional)
Make ConfirmedRoute/PendingMapView fall back to the cached receipt thumbnail when offline instead of the grey placeholder. Broader (helps every offline distance preview) but a larger change; the offline guard on the gate is the smaller, targeted fix.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/98364#issuecomment-5271078061) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting this proposal.
@aimane-chnaif Huh... This is 4 days overdue. Who can take care of this?
@aimane-chnaif how's Melvin proposal looking?
@aimane-chnaif Whoops! This issue is 2 days overdue. Let's get this updated quick!
@Valforte @Gonals @abdulrahuman5196 @aimane-chnaif 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!
@MelvinBot draft implementation for testing purpose
π€ Draft PR created: https://github.com/Expensify/App/pull/99485 (draft β mark it "Ready for review" when it's ready).
What it does: adds an offline guard to the showMapAsImage gate in ReportActionItemImage.tsx β when we're offline and a cached receipt thumbnail exists (hasReceiptSource(transaction)), we skip ConfirmedRoute (which can only draw a blank PendingMapView offline) and fall through to the cached remote thumbnail. Online behavior is unchanged. This is the targeted primary fix from the approved proposal.
Static checks (all pass): TypeScript typecheck, ESLint, React Compiler compliance, cspell.
Automated web test β could not verify at runtime. The web session never reached Home (blank page during drive-to-Home), so I couldn't exercise the offline distance-preview flow. This appears to be a session/bring-up issue rather than something from this change: the changed component (ReportActionItemImage) only mounts inside a report, not during initial bring-up, and the page went blank after ~13 min idle with zero network activity while all static checks pass. Runtime verification of the fix is left to manual testing.
| Step | Status | Observation |
|---|---|---|
| App loads to Home with no JS console errors | β fail | Blank white page during drive-to-Home; snapshot returned 0 nodes; wait text "Home"/"Expensify" timed out; 0 network requests despite dev server + JS bundles serving 200s. Console text couldn't be captured on web. |
| Open a report, expense-preview thumbnails render (no blank placeholder) | β fail | Not reachable β nothing interactive rendered on the blank page. |
Evidence (2)
Last known render (Join/Welcome auth screen) at session prestart
Blank white page during drive-to-Home (session bring-up)
Suggested manual repro to confirm: create a map distance expense with a non-default rate β delete that rate from Workspace > Distance Rates β open the expense and edit the Rate to a different non-default one β return to chat β go offline β the preview map should now stay visible.
@aimane-chnaif Whoops! This issue is 2 days overdue. Let's get this updated quick!
Melvin's solution causes regressions. @Valforte we can open this to external
Proposal
Please re-state the problem that we are trying to solve in this issue.
After editing the rate of a map distance expense (in the repro, the originally-used rate was deleted first), the map disappears from the expense preview every time the user goes offline β the preview shows the gray "pending map" placeholder β and the map reappears when the connection returns. The map should remain visible offline.
What is the root cause of that problem?
A rate edit puts the transaction into a "map receipt is regenerating" state. updateMoneyRequestDistanceRate flags pendingFields.customUnitRateID and additionally pendingFields.merchant for any edit that makes the backend regenerate the map receipt:
https://github.com/Expensify/App/blob/9e1c21f5a44b68d71bb95a0ff63920c56bc2b537/src/libs/actions/IOU/UpdateMoneyRequest.ts#L1578-L1592
While any of these regeneration fields is pending, hasPendingDistanceReceiptRegeneration reports that the stored receipt image is stale:
https://github.com/Expensify/App/blob/9e1c21f5a44b68d71bb95a0ff63920c56bc2b537/src/libs/TransactionUtils/index.ts#L1149-L1165
...and ReportActionItemImage then swaps the receipt thumbnail for the live route map (ConfirmedRoute) so the invalidated receipt URL doesn't render:
https://github.com/Expensify/App/blob/9e1c21f5a44b68d71bb95a0ff63920c56bc2b537/src/components/ReportActionItem/ReportActionItemImage.tsx#L140-L144
The problem is that ConfirmedRoute can only draw the map while online β whenever isOffline is true it renders PendingMapView (the gray placeholder), regardless of the fact that both the route data and the previously stored receipt image are available locally:
https://github.com/Expensify/App/blob/9e1c21f5a44b68d71bb95a0ff63920c56bc2b537/src/components/ConfirmedRoute.tsx#L86-L109
So while the transaction is in the regenerating state, every offline period collapses the receipt frame to the placeholder, and it comes back when online. The reporter's video confirms this exact mechanism: after the rate edit, both the chat preview and the receipt view render the live Mapbox map (Mapbox watermark and attribution visible) instead of the static receipt image, and going offline degrades it to the pending placeholder. In this repro the regenerated receipt for the edit never arrives (the transaction stays in the regenerating state long after the edit β the preview still renders the live map minutes later), so the disappearing map is reproducible on every offline toggle, not just during a brief regeneration window. Note that a rate edit does not change the route, so the locally stored receipt image still shows the correct map β hiding it offline loses information for no benefit.
What changes do you think we should make in order to solve the problem?
In ReportActionItemImage, only swap to the live ConfirmedRoute map when it can actually render. Read the network state with the useNetwork hook and keep the condition that decides to show the map as an image from also requiring the app to be online when a stored receipt image exists: when the user is offline and the transaction still has a stored receipt source, fall through to the existing receipt-thumbnail branch (which renders the locally cached receipt map) instead of rendering ConfirmedRoute.
Behavior after the change: online behavior is untouched β while the receipt regenerates, the live map still replaces the stale receipt URL exactly as today (preserving the fix that introduced this swap). Offline, the preview keeps showing the stored receipt map β which for a rate edit is the correct, unchanged route picture β so the map remains visible after going offline, matching the expected result. Transactions with no stored receipt at all (for example, a brand-new expense whose first receipt hasn't been generated yet) keep the current placeholder behavior.
Compare branch: https://github.com/Expensify/App/compare/main...wildan-m:App:wildan/98364-offline-distance-map?expand=1
What alternative solutions did you explore? (Optional)
Stop treating rate-only edits as receipt-regenerating on the render path, since a rate change does not alter the map picture. Rejected because the backend invalidates the stored receipt URL while it regenerates, so keeping the image branch active online could briefly render a broken image β precisely what the live-map swap was introduced to prevent.
Make ConfirmedRoute itself fall back to the transaction's stored receipt thumbnail when offline instead of rendering PendingMapView. This produces the same user-visible result, but ConfirmedRoute is also used in flows that have no stored receipt (expense creation and confirmation), so the fallback decision belongs in the caller that owns the receipt context.