Keep cached distance map thumbnail visible offline after rate edit - #99485
Keep cached distance map thumbnail visible offline after rate edit#99485MelvinBot wants to merge 2 commits into
Conversation
Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
|
Fixed the failing Oxfmt check — the only real failure. It flagged an Oxfmt diff on the one file this PR touches, The other red check, Check independent approval, is an approval-gate check (not a code failure) and isn't something a code push resolves — it clears once the PR gets the required independent approval. |
|
The real failure — Oxfmt check — is already fixed by commit The only red check left is Check independent approval, which is an approval gate, not a code issue — it clears once the PR receives its required independent approval, so there's nothing for me to push here. |
|
| Step | Status | Observation |
|---|---|---|
| Workspace has 2+ non-default distance rates | ✅ pass | Default Rate €0.76/mi, Rate A €1.25/mi, Rate B €2.50/mi, all Active |
| Map distance expense created using non-default rate | ✅ pass | 9.63 mi @ €1.25/mi (Rate A) = €12.04 — but thumbnail box was already blank gray at creation (online) |
| Delete the just-used rate | ✅ pass | Rate A set Inactive/locked (in use, so disabled rather than hard-deleted); expense flagged "Rate not valid for this workspace" |
| Edit expense Rate to a different non-default rate | ✅ pass | Changed to Rate B (€2.50/mi); amount recalculated to €24.08; system message logged the change |
| Force offline toggled on | ✅ pass | "You appear to be offline" indicator shown |
| Map preview remains visible (no blank placeholder) while offline | ❌ inconclusive | Preview was already blank online before going offline; network log shows recurring failed/pending GETs to www.expensify.com/receipts/… thumbnail URLs, so no thumbnail was ever cached to test persistence against |
| Map preview stays visible after returning online | ✅ pass | No new regression after re-enabling network; preview unchanged (still blank, consistent with pre-offline state) |
No JS console errors observed.
Why the core check couldn't run: The PR's guarded branch (showMapAsImage → && !(isOffline && hasReceiptSource(transaction)) in ReportActionItemImage.tsx) only takes effect when a cached receipt thumbnail exists. In this environment hasReceiptSource(transaction) never became true — the receipt/map thumbnail request never resolved online — so that branch could not be exercised either way. A run in an environment where the Mapbox receipt thumbnail actually renders and caches online (e.g. staging) is needed to confirm the offline-persistence behavior. Note the Android test of the same steps did produce a cached thumbnail and passed.
Screenshots (6)
Workspace Distance rates list with two non-default rates
Distance expense created with Rate A, blank map preview already present online
Rate A shown as Inactive/locked after delete
Expense rate edited to Rate B, amount recalculated
Offline state: report preview still blank, 'You appear to be offline' indicator visible
Back online: report preview unchanged, no regression







Explanation of Change
The expense-preview map for a distance request is normally the remote Mapbox thumbnail (
receipt.source), which stays visible offline because it was cached while online. ButReportActionItemImageswaps that thumbnail for a locally-drawn<ConfirmedRoute>whenevershowMapAsImageis true (isMapDistanceRequest && (hasErrors || hasPendingDistanceReceiptRegeneration(transaction))).When a rate whose original was deleted from the policy is edited, the transaction is left persistently dirty (a lingering
pendingFields/errorFieldsentry), soshowMapAsImagestaystruein the steady state.ConfirmedRoutecannot render a Mapbox map offline — it falls back to a blankPendingMapViewplaceholder — so the map area goes blank every time the user goes offline, and reappears online. That is the exact "disappears offline, reappears online, repeatably" signature in this issue.This change adds an offline guard to the gate: when we're offline and a cached receipt thumbnail exists (
hasReceiptSource(transaction)), we skipConfirmedRouteand fall through to the cached thumbnail branch. Offline, the cached remote thumbnail is strictly better than a blank placeholder. The intended online behavior (draw the live route while the receipt URL is regenerating) is unchanged.Note: this is a draft implementation for testing purposes, as requested.
Fixed Issues
$ #98364
PROPOSAL: #98364 (comment)
Tests
// TODO: The human co-author must fill out the tests you ran before marking this PR as "ready for review". Suggested steps:
Offline tests
QA Steps
// TODO: The human co-author must fill out the QA tests you ran before marking this PR as "ready for review".
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari