Render the generated distance receipt on every New Expensify surface - #98506
Render the generated distance receipt on every New Expensify surface#98506yuwenmemon wants to merge 3 commits into
Conversation
|
@ahmedGaber93 Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8a0e6cee34
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| {isFetchingWaypointsFromServer(transaction) || !thumbnailSource ? ( | ||
| {/* The thumbnail is a page of the stored receipt file, therefore an edit that makes the server | ||
| build a new file also invalidates it. Draw the pending map until the new file arrives. */} | ||
| {hasPendingDistanceReceiptRegeneration(transaction) || !thumbnailSource ? ( |
There was a problem hiding this comment.
Avoid loading stale receipts when the route has errors
When a route or waypoint error occurs while an old receipt source is still present, shouldRenderLocalDistanceEReceipt() now selects this card because hasDistanceRouteErrors() is true, but this condition only suppresses the thumbnail for pending regeneration. The card therefore requests and displays the stale/invalid generated receipt page, while the report receipt tile renders ConfirmedRoute, preserving the cross-surface mismatch this change is meant to remove. Treat route errors like pending regeneration here, or render the locally available route instead.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
(Yuwen's Agent) Good catch — fixed in eef9971. The card now draws the pending map whenever the stored file cannot be trusted, which is hasPendingDistanceReceiptRegeneration || hasDistanceRouteErrors, so the error case no longer loads the stale receipt page while the report tile shows ConfirmedRoute.
@ahmedGaber93 @Valforte please review
Fixed Issues
$ #97013
Details
DistanceEReceiptcard built from the expense, while expanding it rendered the generated file. That is the mismatch in the issue, and it is the only part that is actually broken.shouldRenderLocalDistanceEReceipt, decides between the generated file and the local card, and every surface asks it. The surfaces cannot disagree. The card is the fallback for a file we cannot show: no receipt yet, the server is rebuilding it after an edit, the route errored, or an older expense that stored a bare map image instead of a PDF.distance-manualexpense that still carries waypoints loses the hover card, which matches what expanding it already showed.Worth knowing separately, and not addressed here: the receipt does not have one fixed meaning. A distance edit regenerates it from the Mapbox route, but a rate change regenerates it from the stored billed quantity, so which numbers it carries depends on which edit came last. I will raise that on its own.
Tests
Automated: 372 tests in
tests/unit/TransactionUtilsTest.tsincluding 7 new cases for the predicate, plustests/ui/components/MoneyRequestReceiptViewTest.tsx,tests/ui/IOURequestStepDistanceTest.tsxandtests/unit/components/ReceiptPreviewPositionTest.ts. Typecheck, lint and the React Compiler compliance check pass.