You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-09-14] Distance - Page count remains after reducing waypoints to two when receipt has only one page #100336
Version Number: 9.4.70-0 Reproducible in staging?: Yes Reproducible in production?: N/A - new feature, doesn't exist in prod If this was caught during regression testing, add the test name, ID and link from BrowserStack:#97813 Email or phone of affected tester (no customers):oisdnjonjiodjodjsioj@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Mac 26.5 / Chrome App Component: Money Requests
Action Performed:
Go to staging.new.expensify.com
Go to workspace chat.
Create a map distance expense with many waypoints so that the receipt has more than 1 page.
Open the expense.
Click Distance.
Remove waypoints until there are only two left.
Save the distance.
Expected Result:
Page count will disappear after reducing waypoints to two because receipt has only one page.
Actual Result:
Page count remains after reducing waypoints to two when receipt has only one page.
👋 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.
Classification: Frontend bug Causing PR: #97813 - "Show a page count badge on multi-page PDF receipts" by @ishpaul777 (High confidence) Related Issues: #100332 (StagingDeployCash checklist containing the PR)
Recommendation: ROLL FORWARD
The badge feature is new, self-contained and otherwise working; the only defect is that receipt.pageCount is never invalidated on the distance/waypoint edit path, which is a small additive fix that mirrors the invalidation this same PR already added for the two other receipt-replacement paths. A revert would pull a fully reviewed and unit-tested feature for a stale cosmetic badge.
Assigned: @ishpaul777 (PR author), @abzokhattab and @MonilBhavsar (approving reviewers) — already auto-assigned by melvin-bot, no change needed. Labels: No changes. DeployBlockerCash stays (App PR caused it, fix is in Expensify/App). DeployBlocker was not present, so nothing to remove.
The page count badge did not exist before this PR, which is consistent with "Reproducible in production?: N/A - new feature". The entire symptom (a page count indicator) is introduced by this PR.
The PR is the only thing in the release that reads receipt.pageCount; a repo-wide search finds pageCount on the transaction receipt only in files this PR touched.
The PR itself demonstrates that the author knew a stale pageCount had to be explicitly cleared, and did so on two of the three paths that invalidate a receipt:
replace receipt: src/libs/actions/IOU/Receipt.ts#L213 — pageCount: null with the comment "Clear the old count while the replacement is pending."
Optimistic write that carries the stale receipt forward: UpdateMoneyRequest.ts#L1944-L1953 (Onyx.METHOD.MERGE of {...updatedTransaction, pendingFields, ...}).
Waypoint branch of the optimistic transaction builder: TransactionUtils/index.ts#L834-L905 — getUpdatedTransaction contains no reference to receipt anywhere in its body, so the deep-cloned old receipt (including pageCount) is preserved verbatim.
The unit tests added in the PR (tests/ui/components/MoneyRequestReceiptViewTest.tsx) only assert static Onyx states (pageCount: 3 shows, pageCount: 1 hides, non-PDF hides). There is no test for a transition where the receipt is replaced/regenerated, which is exactly the gap this bug falls into.
Root Cause
receiptPageCount is read straight off Onyx with no tie to the identity of the receipt it describes:
Many-waypoint map distance expense → server generates a multi-page PDF map receipt and sets receipt.pageCount = N (>1). Badge correctly shows "Page 1 of N".
User reduces to two waypoints and saves. updateMoneyRequestDistance flags waypoints/merchant as pending and optimistically merges {...updatedTransaction} into the transaction key. getUpdatedTransaction never touches receipt, so receipt.pageCount is untouched. The badge is temporarily hidden only because isLoading is set to true in the waypoints branch.
The server regenerates a single-page receipt and pushes the new receipt down. Because this is an Onyx MERGE (deep merge), any key the push does not include survives. pageCount is not reset to 1/null, so the old N persists.
isLoading clears, the filename is still a PDF, receiptPageCount is still N > 1 → the badge reappears reading "Page 1 of N" over a one-page receipt.
This is the same stale-value-under-Onyx-MERGE hazard the PR already guarded against in replaceReceipt and getOnyxTargetTransactionData; the distance-regeneration path was simply not covered.
Suggested targeted fix (in src/libs/actions/IOU/UpdateMoneyRequest.ts, at the optimistic transaction merge around L1944-L1953): when shouldFlagMerchantPending is true (i.e. waypoints / distance / customUnitRateID / selectedRouteKey changed, the exact set that makes the BE regenerate the receipt), also clear the count:
value: {
...updatedTransaction,// The BE regenerates the map receipt on this edit, so the old page count no longer describes it.
...(shouldFlagMerchantPending&&updatedTransaction?.receipt ? {receipt: {...updatedTransaction.receipt,pageCount: null}} : {}),
pendingFields,errorFields: null,reportID: newTransactionReportID??updatedTransaction?.reportID,},
An equivalent alternative is to gate the badge on !hasPendingDistanceReceiptRegeneration(displayedTransaction)and clear the count, but gating alone is not sufficient: the stale value survives past the pending window, which is precisely what the tester saw.
One follow-up worth confirming with the fix: whether the regeneration push includes pageCount when the new receipt is still multi-page (e.g. 20 waypoints → 8). If it does not, the badge would be correctly cleared but never restored for that case, and the backend should start emitting pageCount on regenerated distance receipts.
💡 Suggested AI code review rule
This bug looks like a recurring, mechanically detectable pattern, so it may be worth a coding-standards rule so the AI reviewer catches the next one. Proposed for Expensify/App:
Rule:CONSISTENCY-19 Clear new Onyx sub-object fields on every path that replaces the object
Condition: When a PR adds a new optional field to a nested object in src/types/onyx/* (e.g. Transaction['receipt']), every Onyx.METHOD.MERGE / Onyx.merge writer that replaces that parent object must explicitly set the new field, using null when the value is unknown. Onyx merges deeply, so an omitted key keeps its previous value and silently goes stale.
Search pattern: for each field added under src/types/onyx/, list every writer of the parent key — grep -rn "<parentField>:\s*{" src/libs/actions src/libs/*Utils* and grep -rn "\.\.\.<updatedObject>" src/libs/actions — and verify each either assigns the new field or nulls it.
The full rule file, with the ❌/✅ code inline in Expensify/App's coding-standards format, would go in Expensify/App itself. If it's worth adding, a maintainer can open it there as a draft PR.
Nothing is due on this issue. Not $250. abzokhattab approved the offending PR twice, so this regression came from a PR he reviewed.
This is the twin of #100342. Same offending PR, same fix PR, same assignees, same payment date, same Melvin proposal. Paying both is $500. The full reasoning sits on that issue.
Offending PR
#97813 by ishpaul777, merged 2026-09-03. 18 files, +130 / -1
Fix PR
#100357 by ishpaul777, merged 2026-09-04. 4 files, +111 / -1. It fixed this issue and #100342 together
Contributor
Nothing due. ishpaul777 authored the offending PR, and he is a Backend Contributor
abzokhattab approved PR #97813 on 2026-08-14 and again on 2026-09-01, after the backend shipped. He then approved the fix PR on 2026-09-04. That fix work is cleanup of a fault his own approval let through, so it sits inside the original job price and earns nothing here.
Melvin correctly zeroed ishpaul777 as a contractor, then paid the reviewer in full. That is right on an ordinary issue and wrong on a regression issue, because the reviewer is on the offending PR.
This one was more findable than its twin
Worth recording, because it matters if abzokhattab appeals.
Melvin's investigation shows PR #97813 cleared the stale pageCount on two of the three paths that replace a receipt, and missed the third:
Replace receipt, cleared. Receipt.ts#L213, "Clear the old count while the replacement is pending."
Merge transactions, cleared. MergeTransaction.ts#L371, "Clear the old count so it does not describe the newly chosen receipt."
Distance edit, not cleared. This bug.
The correct pattern was in the same diff, twice, with comments explaining it. A reviewer had the answer in front of them.
Two things to handle outside this issue
The penalty belongs on the original job. PR #97813 is titled "[Payment due @abzokhattab]" and closed Expensify/Expensify#667914. That is where abzokhattab gets paid for this work, and that is where the regression cut applies. #97813 caused two confirmed regressions, this one and #100342, and the rule for two or more is 25% of the job price. Worth checking on 667914 before it is paid, if it has not been paid already.
The Contributor+ checklist is still outstanding. It gates the regression test case, not the money, so it does not change anything above. The standing ask: plz complete the Contributor+ checklist and tag me in a post once you have. Thx
On a live run this would tag abzokhattab and MonilBhavsar. It tags nobody here, because the comment carries a test marker.
Claude posting on behalf of Matt. PAYRUBRICTEST v2
Activity
applause-bot commentedon Sep 3, 2026
While Applause doesn't embed attachments for this bug, here are the links for quick view:
https://platform.applause.com/services/links/v1/external/b24608d59d994d716915a6d732ee99c2c8562ff84f6b60a8ba330e949cd8c58b
melvin-bot commentedon Sep 3, 2026
You have been assigned to this deploy blocker because you recently merged this PR: #97813
melvin-bot commentedon Sep 3, 2026
@MonilBhavsar @abzokhattab you have been assigned to this deploy blocker because you reviewed the offending PR: #97813
github-actions commentedon Sep 3, 2026
👋 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:
melvin-bot commentedon Sep 3, 2026
@ishpaul777 you have been assigned to this deploy blocker because you authored the offending PR: #97813
melvin-bot commentedon Sep 3, 2026
💬 A slack conversation has been started in #expensify-open-source
MelvinBot commentedon Sep 3, 2026
🔍 Investigation Summary
Classification: Frontend bug
Causing PR: #97813 - "Show a page count badge on multi-page PDF receipts" by @ishpaul777 (High confidence)
Related Issues: #100332 (StagingDeployCash checklist containing the PR)
Recommendation: ROLL FORWARD
The badge feature is new, self-contained and otherwise working; the only defect is that
receipt.pageCountis never invalidated on the distance/waypoint edit path, which is a small additive fix that mirrors the invalidation this same PR already added for the two other receipt-replacement paths. A revert would pull a fully reviewed and unit-tested feature for a stale cosmetic badge.Assigned: @ishpaul777 (PR author), @abzokhattab and @MonilBhavsar (approving reviewers) — already auto-assigned by melvin-bot, no change needed.
Labels: No changes.
DeployBlockerCashstays (App PR caused it, fix is inExpensify/App).DeployBlockerwas not present, so nothing to remove.📋 Detailed Analysis
Evidence
2026-09-03T18:04:45Z; this issue was filed2026-09-03T19:08:57Z, ~1 hour later. It is in the openStagingDeployCashchecklist Deploy Checklist: New Expensify 2026-09-03 #100332.receipt.pageCount; a repo-wide search findspageCounton the transaction receipt only in files this PR touched.pageCounthad to be explicitly cleared, and did so on two of the three paths that invalidate a receipt:src/libs/actions/IOU/Receipt.ts#L213—pageCount: nullwith the comment "Clear the old count while the replacement is pending."src/libs/actions/MergeTransaction.ts#L371— "Clear the old count so it does not describe the newly chosen receipt."Verification
Affected files (all line links pinned to the PR merge commit
649427c):MoneyRequestReceiptView.tsx#L203,#L560,#L718-L723— all three added by [Payment due @abzokhattab] Show a page count badge on multi-page PDF receipts #97813.UpdateMoneyRequest.ts#L1944-L1953(Onyx.METHOD.MERGEof{...updatedTransaction, pendingFields, ...}).TransactionUtils/index.ts#L834-L905—getUpdatedTransactioncontains no reference toreceiptanywhere in its body, so the deep-cloned old receipt (includingpageCount) is preserved verbatim.TransactionUtils/index.ts#L1418-L1432(waypoints,distance,merchant,customUnitRateID).The unit tests added in the PR (
tests/ui/components/MoneyRequestReceiptViewTest.tsx) only assert static Onyx states (pageCount: 3shows,pageCount: 1hides, non-PDF hides). There is no test for a transition where the receipt is replaced/regenerated, which is exactly the gap this bug falls into.Root Cause
receiptPageCountis read straight off Onyx with no tie to the identity of the receipt it describes:Sequence for the repro:
receipt.pageCount = N (>1). Badge correctly shows "Page 1 of N".updateMoneyRequestDistanceflagswaypoints/merchantas pending and optimistically merges{...updatedTransaction}into the transaction key.getUpdatedTransactionnever touchesreceipt, soreceipt.pageCountis untouched. The badge is temporarily hidden only becauseisLoadingis set totruein the waypoints branch.receiptdown. Because this is an OnyxMERGE(deep merge), any key the push does not include survives.pageCountis not reset to1/null, so the oldNpersists.isLoadingclears, the filename is still a PDF,receiptPageCountis stillN > 1→ the badge reappears reading "Page 1 of N" over a one-page receipt.This is the same stale-value-under-Onyx-MERGE hazard the PR already guarded against in
replaceReceiptandgetOnyxTargetTransactionData; the distance-regeneration path was simply not covered.Suggested targeted fix (in
src/libs/actions/IOU/UpdateMoneyRequest.ts, at the optimistic transaction merge around L1944-L1953): whenshouldFlagMerchantPendingis true (i.e.waypoints/distance/customUnitRateID/selectedRouteKeychanged, the exact set that makes the BE regenerate the receipt), also clear the count:An equivalent alternative is to gate the badge on
!hasPendingDistanceReceiptRegeneration(displayedTransaction)and clear the count, but gating alone is not sufficient: the stale value survives past the pending window, which is precisely what the tester saw.One follow-up worth confirming with the fix: whether the regeneration push includes
pageCountwhen the new receipt is still multi-page (e.g. 20 waypoints → 8). If it does not, the badge would be correctly cleared but never restored for that case, and the backend should start emittingpageCounton regenerated distance receipts.💡 Suggested AI code review rule
This bug looks like a recurring, mechanically detectable pattern, so it may be worth a coding-standards rule so the AI reviewer catches the next one. Proposed for
Expensify/App:CONSISTENCY-19Clear new Onyx sub-object fields on every path that replaces the objectsrc/types/onyx/*(e.g.Transaction['receipt']), everyOnyx.METHOD.MERGE/Onyx.mergewriter that replaces that parent object must explicitly set the new field, usingnullwhen the value is unknown. Onyx merges deeply, so an omitted key keeps its previous value and silently goes stale.receipt.pageCountand cleared it in the replace-receipt and merge-transaction paths, but not in the distance-edit path, so a reduced-waypoint expense kept showing "Page 1 of 3" over a one-page receipt (this deploy blocker).src/types/onyx/, list every writer of the parent key —grep -rn "<parentField>:\s*{" src/libs/actions src/libs/*Utils*andgrep -rn "\.\.\.<updatedObject>" src/libs/actions— and verify each either assigns the new field or nulls it.App/src/libs/actions/IOU/UpdateMoneyRequest.ts
Lines 1944 to 1953 in 649427c
App/src/libs/actions/IOU/Receipt.ts
Line 213 in 649427c
App/src/libs/actions/MergeTransaction.ts
Line 371 in 649427c
The full rule file, with the ❌/✅ code inline in
Expensify/App's coding-standards format, would go inExpensify/Appitself. If it's worth adding, a maintainer can open it there as a draft PR.view run
14 remaining items
melvin-bot commentedon Sep 13, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)melvin-bot commentedon Sep 13, 2026
Payment Summary
Resolving PRs:
[CP Staging] Fix stale/missing receipt page count badge across distance edits #100357
Reviewer: @abzokhattab owed $250 via NewDot
Contributor: @ishpaul777 does not require payment (Contractor)
BugZero Checklist (@mallenexpensify)
mallenexpensify commentedon Sep 16, 2026
Claude posting on behalf of Matt:
Nothing is due on this issue. Not $250.
abzokhattabapproved the offending PR twice, so this regression came from a PR he reviewed.This is the twin of #100342. Same offending PR, same fix PR, same assignees, same payment date, same Melvin proposal. Paying both is $500. The full reasoning sits on that issue.
ishpaul777, merged 2026-09-03. 18 files, +130 / -1ishpaul777, merged 2026-09-04. 4 files, +111 / -1. It fixed this issue and #100342 togetherishpaul777authored the offending PR, and he is a Backend Contributorabzokhattabapproved the offending PR on 2026-08-14 and approved it again on 2026-09-01abzokhattababzokhattabappealsWhy nothing is due
Melvin named the reviewers itself: "@MonilBhavsar @abzokhattab you have been assigned to this deploy blocker because you reviewed the offending PR".
abzokhattabapproved PR #97813 on 2026-08-14 and again on 2026-09-01, after the backend shipped. He then approved the fix PR on 2026-09-04. That fix work is cleanup of a fault his own approval let through, so it sits inside the original job price and earns nothing here.Melvin correctly zeroed
ishpaul777as a contractor, then paid the reviewer in full. That is right on an ordinary issue and wrong on a regression issue, because the reviewer is on the offending PR.This one was more findable than its twin
Worth recording, because it matters if
abzokhattabappeals.Melvin's investigation shows PR #97813 cleared the stale
pageCounton two of the three paths that replace a receipt, and missed the third:Receipt.ts#L213, "Clear the old count while the replacement is pending."MergeTransaction.ts#L371, "Clear the old count so it does not describe the newly chosen receipt."The correct pattern was in the same diff, twice, with comments explaining it. A reviewer had the answer in front of them.
Two things to handle outside this issue
The penalty belongs on the original job. PR #97813 is titled "[Payment due @abzokhattab]" and closed Expensify/Expensify#667914. That is where
abzokhattabgets paid for this work, and that is where the regression cut applies. #97813 caused two confirmed regressions, this one and #100342, and the rule for two or more is 25% of the job price. Worth checking on 667914 before it is paid, if it has not been paid already.The Contributor+ checklist is still outstanding. It gates the regression test case, not the money, so it does not change anything above. The standing ask: plz complete the Contributor+ checklist and tag me in a post once you have. Thx
On a live run this would tag
abzokhattabandMonilBhavsar. It tags nobody here, because the comment carries a test marker.Claude posting on behalf of Matt.
PAYRUBRICTEST v2mallenexpensify commentedon Sep 16, 2026
Going to close as not due payment, will leave open for a pass in case anyone wants to comment
abzokhattab commentedon Sep 23, 2026
Can be closed as its handled in #100336