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-06-01] [$250] Expense - Marked as paid message is shown twice on receipt cropped expense. #89131
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Version Number: V9.3.62-6 Reproducible in staging?: Yes Reproducible in production?: Yes If this was caught during regression testing, add the test name, ID and link from BrowserStack:https://test-management.browserstack.com/projects/2219752/folder/13176924/test-cases/41237576 Email or phone of affected tester (no customers):dreamnitethedragon+vegst@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Significant User Experience Deterioration Device used: Redmi note 10s android 13 App Component: Money Requests
Action Performed:
Launch app
Login with new gmail account and complete onboarding via Get paid back by employer
Tap fab - create expense - try it out
Tap receipt and crop the receipt
Tap create expense
Open the expense
Expected Result:
Marked as paid message must not be shown twice on receipt cropped expense.
Actual Result:
Marked as paid message is shown twice on receipt cropped expense.
buildOnyxDataForTestDriveIOU (index.ts:1092-1152) creates an optimistic PAY action that overwrites the original CREATE action at the samereportActionID (line 1108). However, successData and failureData are left empty (lines 1096-1097), so this optimistic overwrite is never cleaned up.
When the server processes REQUEST_MONEY with isTestDrive=true (TrackExpense.ts:1807), it auto-settles the expense and creates its own PAY action with a new server-generated reportActionID. Meanwhile, the parent buildOnyxDataForMoneyRequest success callback only clears pendingAction/errors on the original reportActionID (lines 1625-1629) — it does not revert the action type from PAY back to CREATE.
Result: two PAY actions coexist in Onyx (the stuck optimistic one + the server-generated one), and both render as "marked as paid" via PaymentContent.tsx:30-31.
What changes do you think we should make in order to solve the problem?
Add successData to buildOnyxDataForTestDriveIOU that removes the optimistic PAY action at iou.action.reportActionID once the server responds (since the server creates the real PAY action with its own ID). This can be done by pushing an entry to successData that sets the action to null at that key, effectively cleaning up the optimistic overwrite:
Alternatively, the successData could revert the action's originalMessage.type back to CREATE instead of removing it, so the original CREATE action is restored and only the server's PAY action shows "marked as paid".
What alternative solutions did you explore? (Optional)
Another approach would be to deduplicate PAY-type actions in shouldReportActionBeVisible in ReportActionsUtils.ts, but this treats the symptom rather than the root cause. The optimistic action should be properly cleaned up in successData to keep the data layer accurate.
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.
changed the title [-]Expense - Marked as paid message is shown twice on receipt cropped expense.[/-][+][$250] Expense - Marked as paid message is shown twice on receipt cropped expense.[/+]on Apr 28, 2026
Please re-state the problem that we are trying to solve in this issue.
In the test-drive flow ("Try it out"), when you scan a receipt and tap Create expense, the resulting expense thread renders the "Marked as paid" / "Paid elsewhere" message twice on the iouReport, instead of once. The duplication is reproducible on Android, iOS, and Windows Chrome (matching the issue's checked platforms) and is reproducible in staging and production.
What is the root cause of that problem?
buildOnyxDataForTestDriveIOU (src/libs/actions/IOU/index.ts L1092-L1152) optimistically writes a PAY-type IOU report action under the samereportActionID that is already being used by the optimistic CREATE action of the parent flow:
The optimistic PAY is built with type: PAY, paymentType: ELSEWHERE, and reportActionID: testDriveIOUParams.iouOptimisticParams.action.reportActionID (lines 1099-1109).
It is then pushed into optimisticData at ${REPORT_ACTIONS}${iouReportID} keyed by that same iou.action.reportActionID, overwriting the optimistic CREATE action at that key (lines 1138-1144).
The function declares successData and failureData empty (lines 1096-1097) and returns them empty (lines 1147-1151), so this overwrite is never reverted or cleaned up.
When REQUEST_MONEY runs with isTestDrive=true (src/libs/actions/IOU/TrackExpense.ts L1807), the server auto-settles the expense and returns its own PAY action with a new server-generated reportActionID (separate from iou.action.reportActionID). The parent buildOnyxDataForMoneyRequest success callback at src/libs/actions/IOU/index.ts L1625-L1629 only clears pendingAction / errors / isOptimisticAction on iou.action.reportActionID — it does not revert the action's type back to CREATE, and it does not delete the stuck optimistic PAY.
Trigger → mechanism → impact: end of the optimistic build leaves a PAY action at iou.action.reportActionID; the server response adds a second PAY action at a new ID; both pass shouldReportActionBeVisible, both reach PaymentContent (src/pages/inbox/report/actionContents/PaymentContent.tsx L30-L31) with paymentType === ELSEWHERE, so both render iou.paidElsewhere ("Marked as paid"). Hence the duplicate message.
// delegateAccountIDParam: will be threaded in PR 15; buildOptimisticAddCommentReportAction falls back to module-level Onyx.connect value (https://github.com/Expensify/App/issues/66425)
What changes do you think we should make in order to solve the problem?
The optimistic PAY produced by buildOnyxDataForTestDriveIOU is the duplicate that must be cleaned up once the server returns its own PAY action. Two viable shapes:
Minimal patch. Inside buildOnyxDataForTestDriveIOU, push a successData entry that nulls the optimistic PAY action at ${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouOptimisticParams.report.reportID} keyed by iouOptimisticParams.action.reportActionID. Mirror the same null in failureData so an offline-then-failed retry also leaves the report in a sane state (otherwise a failed test-drive submission would leave the same stuck PAY action behind). The server-supplied CREATE and PAY (each at their own new reportActionID) survive — matching the non-test-drive happy path.
Cleaner data shape. Stop overwriting iou.action.reportActionID. Generate a unique reportActionID via NumberUtils.rand64() for the optimistic PAY in buildOnyxDataForTestDriveIOU, push it into optimisticData under that new key, and null it in both successData and failureData. The optimistic CREATE then survives unchanged at its original key, and CREATE/PAY never share a reportActionID. This is invariant-preserving and is the path I'd recommend if a slightly broader change is acceptable.
Either shape addresses the same root cause (the missing cleanup); option 2 also removes the brittle "PAY masquerades as CREATE under the CREATE's reportActionID" intermediate state.
Scope boundaries. Edits are confined to one function (buildOnyxDataForTestDriveIOU) in src/libs/actions/IOU/index.ts. The fix lives in shared JS so it covers Android, iOS, and web (the three platforms checked on the issue). Explicitly not touched: the non-test-drive REQUEST_MONEY path, the manager-McTest branch at src/libs/actions/IOU/index.ts L1418+ (which has its own PAY-overwrite logic and is not affected by this bug), src/libs/actions/IOU/TrackExpense.ts, PaymentContent.tsx, and ReportActionsUtils.shouldReportActionBeVisible. No backend / API contract change.
What alternative solutions did you explore? (Optional)
MelvinBot's primary suggestion (post successData that nulls the optimistic action at iou.action.reportActionID) identifies the same root cause and lands at the same fix as option 1 above. That part of the bot proposal is correct.
MelvinBot's alternative (deduplicate PAY actions inside shouldReportActionBeVisible in src/libs/ReportActionsUtils.ts) should be rejected: it suppresses the second message in the UI without correcting the stale optimistic state in Onyx, which still leaks into other consumers (search snapshots, lastActionType, report previews, RBR / counters, exports). It treats the symptom and creates a maintenance trap.
Server-side cleanup (have the REQUEST_MONEYonyxData for isTestDrive=true explicitly null iou.action.reportActionID on success) would also work, but is a backend change. The client-only fix above is preferred for being merge-ready in this repo.
Bypassing the overwrite by always rendering only the most recent PAY (e.g., suppressing earlier PAY actions in PaymentContent) was considered and rejected for the same "treat the symptom" reason as the dedup alternative above.
⚠️@ProjectNOVACo Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.
The test-drive receipt flow temporarily overwrites the original money-request IOU action with a PAY action, using the same reportActionID.
In buildOnyxDataForTestDriveIOU, the optimistic action is built with type: CONST.IOU.REPORT_ACTION_TYPE.PAY and paymentType: ELSEWHERE, but it reuses iouOptimisticParams.action.reportActionID:
The generic money-request success data only clears pending/error fields on the original action ID; it does not restore the original CREATE action content:
As a result, the report contains two PAY actions: the stuck optimistic PAY action and the real server-created PAY action. PaymentContent renders each ELSEWHERE PAY action as “marked as paid”, so the message appears twice:
What changes do you think we should make in order to solve the problem?
Restore the original optimistic IOU CREATE action in buildOnyxDataForTestDriveIOU after the API response instead of leaving the temporary PAY action in Onyx.
Required changes:
Add a shared iouReportActionsKey for the IOU report actions collection.
Add successData that merges iouOptimisticParams.action back at iouOptimisticParams.action.reportActionID.
Add matching failureData so a failed test-drive request also returns the report action to the normal CREATE state before the existing failure-data error merge runs.
Keep the real server-generated PAY action untouched; it remains the only action rendered as “marked as paid”.
Tests to add:
Add a unit test around buildOnyxDataForMoneyRequest or getMoneyRequestInformation for a transaction with receipt.isTestDriveReceipt = true.
Assert that optimistic data still temporarily writes a PAY action for the test-drive flow.
Assert that success data restores the original CREATE IOU action at the same reportActionID.
Assert that failure data also restores the original CREATE IOU action.
MelvinBot identified the correct data-layer area, but the concrete cleanup should restore the original CREATE action rather than remove the action. Removing the action can hide the original money-request action from the report, while restoring it preserves the expense entry and leaves only the backend-created PAY action to render “marked as paid”.
I also considered deduplicating PAY actions in ReportActionsUtils or PaymentContent, but that would hide a corrupted Onyx state instead of fixing the optimistic update that creates it.
What alternative solutions did you explore? (Optional)
⚠️@nabi-ebrahimi Your proposal is a duplicate of an already existing proposal and has been automatically withdrawn to prevent spam. Please review the existing proposals before submitting a new one.
Please re-state the problem that we are trying to solve in this issue.
When a new user goes through the "Try it out" scan-test flow from the FAB, taps the receipt thumbnail in the confirmation step, crops the receipt, and then submits the expense, the resulting expense thread shows the "marked as paid" system message twice. Without cropping the test receipt first, the message correctly appears only once.
What is the root cause of that problem?
The "Try it out" tooltip starts the scan-test flow by calling setMoneyRequestReceipt with isTestReceipt = true, which stamps that flag onto the draft transaction's receipt. The downstream optimistic logic in buildOnyxDataForMoneyRequest reads this flag to decide whether to mark the optimistic IOU report action as PAY with payment type ELSEWHERE (which is what PaymentContent renders as "marked as paid") and to set the optimistic lastActionType: MARKED_REIMBURSED on the iouReport:
When the user taps the receipt thumbnail and crops it on the confirmation step, the crop's "save" handler calls applyDurableReceipt, which for a draft transaction invokes setMoneyRequestReceipt without forwarding the receipt's existing test flags:
setMoneyRequestReceipt has its isTestReceipt and isTestDriveReceipt parameters defaulted to false, and explicitly merges them as null onto the receipt object — which clears the flags whenever a value isn't supplied:
So after the crop, transaction.receipt.isTestReceipt is null. When the user taps "Create expense", the Manager McTest branch in buildOnyxDataForMoneyRequest evaluates isScanRequest && !isTestReceipt as true and picks the CREATE / no-paymentType variant, also skipping the optimistic lastActionType: MARKED_REIMBURSED update on the iouReport. The transaction is still treated as a demo on the server because the participant is Manager McTest (isDemoTransactionParam is derived from the participant login, not the receipt flag), so the backend auto-pays it and returns a server-generated IOU PAY / ELSEWHERE action plus a MARKED_REIMBURSED action. With no optimistic PAY action holding the same reportActionID to merge into, both server actions land independently in the chat — one rendering "marked as paid" through PaymentContent and the other through SimpleMessageContent, producing the observed duplicate.
The same gap affects the rotate button on the same modal because it shares applyDurableReceipt, but the user-visible repro is the crop button.
What changes do you think we should make in order to solve the problem?
In applyDurableReceipt inside TransactionReceiptModalContent.tsx, when the draft-transaction branch calls setMoneyRequestReceipt, forward the receipt's existing isTestReceipt and isTestDriveReceipt values from transaction.receipt instead of letting them default to false. With the flag preserved across the crop and rotate operations, the downstream optimistic branch in buildOnyxDataForMoneyRequest once again selects the PAY / ELSEWHERE path and emits the matching optimistic IOU action plus the optimistic lastActionType: MARKED_REIMBURSED. The server's PAY response merges into the same reportActionID rather than landing as an independent action, and only one "marked as paid" message renders — matching the no-crop behavior.
The fix is a single-call-site change at the boundary between the receipt-modify UI and the receipt store; it doesn't require any behavioral changes in the IOU optimistic-data builder. It's also robust against future scan-test or test-drive flows that depend on flags surviving in-place receipt edits — even though the rotate-and-crop button is currently hidden for test-drive receipts via shouldShowRotateAndCropReceiptButton, mirroring the same forward for isTestDriveReceipt keeps the two flags symmetric at this boundary.
What alternative solutions did you explore? (Optional)
A broader alternative is to change the optimistic-data heuristic in buildOnyxDataForMoneyRequest so the PAY / ELSEWHERE branch is taken whenever the participant is Manager McTest, regardless of whether the receipt flag is still present — effectively aligning the optimistic side with the isDemoTransactionParam rule already used for the API call. This is a wider blast radius (every Manager McTest expense path is affected, including non-scan ones) and feels closer to a behavioral redesign than a bug fix, so the surgical preserve-on-edit approach above is preferable for this issue.
But we knowingly introduced a regression as a result of the change, so shouldn't the FE PR have been placed on hold for a BE PR to come first to avoid that? CC: @roryabraham as you were the internal reviewer on the PR.
@roryabraham 👀 above please. I think it would have been better to place this on hold but.. it's water under the bridge now and the regression wasn't unexpected so I think it's likely best to pay both @mkhutornyi and @samarroy84 $250 and move on (assuming it's ready to be closed, I'm not well-versed in everything here)
Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributor
Activity
MelvinBot commentedon Apr 28, 2026
Proposal
What is the root cause of that problem?
buildOnyxDataForTestDriveIOU(index.ts:1092-1152) creates an optimistic PAY action that overwrites the original CREATE action at the samereportActionID(line 1108). However,successDataandfailureDataare left empty (lines 1096-1097), so this optimistic overwrite is never cleaned up.When the server processes
REQUEST_MONEYwithisTestDrive=true(TrackExpense.ts:1807), it auto-settles the expense and creates its own PAY action with a new server-generatedreportActionID. Meanwhile, the parentbuildOnyxDataForMoneyRequestsuccess callback only clearspendingAction/errorson the originalreportActionID(lines 1625-1629) — it does not revert the action type from PAY back to CREATE.Result: two PAY actions coexist in Onyx (the stuck optimistic one + the server-generated one), and both render as "marked as paid" via
PaymentContent.tsx:30-31.What changes do you think we should make in order to solve the problem?
Add
successDatatobuildOnyxDataForTestDriveIOUthat removes the optimistic PAY action atiou.action.reportActionIDonce the server responds (since the server creates the real PAY action with its own ID). This can be done by pushing an entry tosuccessDatathat sets the action tonullat that key, effectively cleaning up the optimistic overwrite:Alternatively, the
successDatacould revert the action'soriginalMessage.typeback toCREATEinstead of removing it, so the original CREATE action is restored and only the server's PAY action shows "marked as paid".What alternative solutions did you explore? (Optional)
Another approach would be to deduplicate PAY-type actions in
shouldReportActionBeVisibleinReportActionsUtils.ts, but this treats the symptom rather than the root cause. The optimistic action should be properly cleaned up insuccessDatato keep the data layer accurate.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.melvin-bot commentedon Apr 28, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @mkhutornyi (
External)[-]Expense - Marked as paid message is shown twice on receipt cropped expense.[/-][+][$250] Expense - Marked as paid message is shown twice on receipt cropped expense.[/+]melvin-bot commentedon Apr 28, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022049214584338062184
KJ21-ENG commentedon Apr 28, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
In the test-drive flow ("Try it out"), when you scan a receipt and tap Create expense, the resulting expense thread renders the "Marked as paid" / "Paid elsewhere" message twice on the iouReport, instead of once. The duplication is reproducible on Android, iOS, and Windows Chrome (matching the issue's checked platforms) and is reproducible in staging and production.
What is the root cause of that problem?
buildOnyxDataForTestDriveIOU(src/libs/actions/IOU/index.tsL1092-L1152) optimistically writes a PAY-type IOU report action under the samereportActionIDthat is already being used by the optimistic CREATE action of the parent flow:type: PAY,paymentType: ELSEWHERE, andreportActionID: testDriveIOUParams.iouOptimisticParams.action.reportActionID(lines 1099-1109).optimisticDataat${REPORT_ACTIONS}${iouReportID}keyed by that sameiou.action.reportActionID, overwriting the optimistic CREATE action at that key (lines 1138-1144).successDataandfailureDataempty (lines 1096-1097) and returns them empty (lines 1147-1151), so this overwrite is never reverted or cleaned up.When
REQUEST_MONEYruns withisTestDrive=true(src/libs/actions/IOU/TrackExpense.tsL1807), the server auto-settles the expense and returns its own PAY action with a new server-generatedreportActionID(separate fromiou.action.reportActionID). The parentbuildOnyxDataForMoneyRequestsuccess callback atsrc/libs/actions/IOU/index.tsL1625-L1629 only clearspendingAction/errors/isOptimisticActiononiou.action.reportActionID— it does not revert the action's type back to CREATE, and it does not delete the stuck optimistic PAY.Trigger → mechanism → impact: end of the optimistic build leaves a PAY action at
iou.action.reportActionID; the server response adds a second PAY action at a new ID; both passshouldReportActionBeVisible, both reachPaymentContent(src/pages/inbox/report/actionContents/PaymentContent.tsxL30-L31) withpaymentType === ELSEWHERE, so both renderiou.paidElsewhere("Marked as paid"). Hence the duplicate message.App/src/libs/actions/IOU/index.ts
Lines 1092 to 1152 in d7cdde1
App/src/libs/actions/IOU/index.ts
Lines 1612 to 1631 in d7cdde1
What changes do you think we should make in order to solve the problem?
The optimistic PAY produced by
buildOnyxDataForTestDriveIOUis the duplicate that must be cleaned up once the server returns its own PAY action. Two viable shapes:Minimal patch. Inside
buildOnyxDataForTestDriveIOU, push asuccessDataentry that nulls the optimistic PAY action at${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouOptimisticParams.report.reportID}keyed byiouOptimisticParams.action.reportActionID. Mirror the same null infailureDataso an offline-then-failed retry also leaves the report in a sane state (otherwise a failed test-drive submission would leave the same stuck PAY action behind). The server-supplied CREATE and PAY (each at their own newreportActionID) survive — matching the non-test-drive happy path.Cleaner data shape. Stop overwriting
iou.action.reportActionID. Generate a uniquereportActionIDviaNumberUtils.rand64()for the optimistic PAY inbuildOnyxDataForTestDriveIOU, push it intooptimisticDataunder that new key, and null it in bothsuccessDataandfailureData. The optimistic CREATE then survives unchanged at its original key, and CREATE/PAY never share a reportActionID. This is invariant-preserving and is the path I'd recommend if a slightly broader change is acceptable.Either shape addresses the same root cause (the missing cleanup); option 2 also removes the brittle "PAY masquerades as CREATE under the CREATE's reportActionID" intermediate state.
Scope boundaries. Edits are confined to one function (
buildOnyxDataForTestDriveIOU) insrc/libs/actions/IOU/index.ts. The fix lives in shared JS so it covers Android, iOS, and web (the three platforms checked on the issue). Explicitly not touched: the non-test-driveREQUEST_MONEYpath, the manager-McTest branch atsrc/libs/actions/IOU/index.tsL1418+ (which has its own PAY-overwrite logic and is not affected by this bug),src/libs/actions/IOU/TrackExpense.ts,PaymentContent.tsx, andReportActionsUtils.shouldReportActionBeVisible. No backend / API contract change.What alternative solutions did you explore? (Optional)
successDatathat nulls the optimistic action atiou.action.reportActionID) identifies the same root cause and lands at the same fix as option 1 above. That part of the bot proposal is correct.shouldReportActionBeVisibleinsrc/libs/ReportActionsUtils.ts) should be rejected: it suppresses the second message in the UI without correcting the stale optimistic state in Onyx, which still leaks into other consumers (search snapshots,lastActionType, report previews, RBR / counters, exports). It treats the symptom and creates a maintenance trap.REQUEST_MONEYonyxDataforisTestDrive=trueexplicitly nulliou.action.reportActionIDon success) would also work, but is a backend change. The client-only fix above is preferred for being merge-ready in this repo.PaymentContent) was considered and rejected for the same "treat the symptom" reason as the dedup alternative above.ProjectNOVACo commentedon Apr 28, 2026
🚫 Duplicated proposal withdrawn by 🤖 ProposalPolice.
ProjectNOVACo commentedon Apr 28, 2026
📋 Contributor details
github-actions commentedon Apr 28, 2026
nabi-ebrahimi commentedon Apr 28, 2026
Proposal
What is the root cause of that problem?
The test-drive receipt flow temporarily overwrites the original money-request IOU action with a PAY action, using the same
reportActionID.In
buildOnyxDataForTestDriveIOU, the optimistic action is built withtype: CONST.IOU.REPORT_ACTION_TYPE.PAYandpaymentType: ELSEWHERE, but it reusesiouOptimisticParams.action.reportActionID:App/src/libs/actions/IOU/index.ts
Lines 1092 to 1108 in d7cdde1
That PAY action is merged into the IOU report actions collection at the same key as the original CREATE action:
App/src/libs/actions/IOU/index.ts
Lines 1138 to 1144 in d7cdde1
However, the helper returns empty
successDataandfailureData, so the overwritten CREATE action is never restored:App/src/libs/actions/IOU/index.ts
Lines 1147 to 1151 in d7cdde1
The test-drive
REQUEST_MONEYcall also sendsisTestDrive, which lets the backend auto-settle the request and return the real PAY action separately:App/src/libs/actions/IOU/TrackExpense.ts
Lines 1778 to 1809 in d7cdde1
The generic money-request success data only clears pending/error fields on the original action ID; it does not restore the original CREATE action content:
App/src/libs/actions/IOU/index.ts
Lines 1608 to 1623 in d7cdde1
As a result, the report contains two PAY actions: the stuck optimistic PAY action and the real server-created PAY action.
PaymentContentrenders each ELSEWHERE PAY action as “marked as paid”, so the message appears twice:App/src/pages/inbox/report/actionContents/PaymentContent.tsx
Lines 27 to 31 in d7cdde1
What changes do you think we should make in order to solve the problem?
Restore the original optimistic IOU CREATE action in
buildOnyxDataForTestDriveIOUafter the API response instead of leaving the temporary PAY action in Onyx.Required changes:
iouReportActionsKeyfor the IOU report actions collection.successDatathat mergesiouOptimisticParams.actionback atiouOptimisticParams.action.reportActionID.failureDataso a failed test-drive request also returns the report action to the normal CREATE state before the existing failure-data error merge runs.Tests to add:
buildOnyxDataForMoneyRequestorgetMoneyRequestInformationfor a transaction withreceipt.isTestDriveReceipt = true.reportActionID.MelvinBot identified the correct data-layer area, but the concrete cleanup should restore the original CREATE action rather than remove the action. Removing the action can hide the original money-request action from the report, while restoring it preserves the expense entry and leaves only the backend-created PAY action to render “marked as paid”.
I also considered deduplicating PAY actions in
ReportActionsUtilsorPaymentContent, but that would hide a corrupted Onyx state instead of fixing the optimistic update that creates it.What alternative solutions did you explore? (Optional)
github-actions commentedon Apr 28, 2026
wildan-m commentedon Apr 28, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a new user goes through the "Try it out" scan-test flow from the FAB, taps the receipt thumbnail in the confirmation step, crops the receipt, and then submits the expense, the resulting expense thread shows the "marked as paid" system message twice. Without cropping the test receipt first, the message correctly appears only once.
What is the root cause of that problem?
The "Try it out" tooltip starts the scan-test flow by calling
setMoneyRequestReceiptwithisTestReceipt = true, which stamps that flag onto the draft transaction's receipt. The downstream optimistic logic inbuildOnyxDataForMoneyRequestreads this flag to decide whether to mark the optimistic IOU report action as PAY with payment type ELSEWHERE (which is whatPaymentContentrenders as "marked as paid") and to set the optimisticlastActionType: MARKED_REIMBURSEDon the iouReport:App/src/libs/actions/IOU/index.ts
Lines 1418 to 1478 in d7cdde1
When the user taps the receipt thumbnail and crops it on the confirmation step, the crop's "save" handler calls
applyDurableReceipt, which for a draft transaction invokessetMoneyRequestReceiptwithout forwarding the receipt's existing test flags:App/src/pages/media/AttachmentModalScreen/routes/TransactionReceiptModalContent.tsx
Lines 288 to 312 in d7cdde1
setMoneyRequestReceipthas itsisTestReceiptandisTestDriveReceiptparameters defaulted tofalse, and explicitly merges them asnullonto the receipt object — which clears the flags whenever a value isn't supplied:App/src/libs/actions/IOU/Receipt.ts
Lines 293 to 307 in d7cdde1
So after the crop,
transaction.receipt.isTestReceiptis null. When the user taps "Create expense", the Manager McTest branch inbuildOnyxDataForMoneyRequestevaluatesisScanRequest && !isTestReceiptas true and picks the CREATE / no-paymentType variant, also skipping the optimisticlastActionType: MARKED_REIMBURSEDupdate on the iouReport. The transaction is still treated as a demo on the server because the participant is Manager McTest (isDemoTransactionParamis derived from the participant login, not the receipt flag), so the backend auto-pays it and returns a server-generated IOU PAY / ELSEWHERE action plus a MARKED_REIMBURSED action. With no optimistic PAY action holding the same reportActionID to merge into, both server actions land independently in the chat — one rendering "marked as paid" throughPaymentContentand the other throughSimpleMessageContent, producing the observed duplicate.The same gap affects the rotate button on the same modal because it shares
applyDurableReceipt, but the user-visible repro is the crop button.What changes do you think we should make in order to solve the problem?
In
applyDurableReceiptinsideTransactionReceiptModalContent.tsx, when the draft-transaction branch callssetMoneyRequestReceipt, forward the receipt's existingisTestReceiptandisTestDriveReceiptvalues fromtransaction.receiptinstead of letting them default to false. With the flag preserved across the crop and rotate operations, the downstream optimistic branch inbuildOnyxDataForMoneyRequestonce again selects the PAY / ELSEWHERE path and emits the matching optimistic IOU action plus the optimisticlastActionType: MARKED_REIMBURSED. The server's PAY response merges into the same reportActionID rather than landing as an independent action, and only one "marked as paid" message renders — matching the no-crop behavior.The fix is a single-call-site change at the boundary between the receipt-modify UI and the receipt store; it doesn't require any behavioral changes in the IOU optimistic-data builder. It's also robust against future scan-test or test-drive flows that depend on flags surviving in-place receipt edits — even though the rotate-and-crop button is currently hidden for test-drive receipts via
shouldShowRotateAndCropReceiptButton, mirroring the same forward forisTestDriveReceiptkeeps the two flags symmetric at this boundary.What alternative solutions did you explore? (Optional)
A broader alternative is to change the optimistic-data heuristic in
buildOnyxDataForMoneyRequestso the PAY / ELSEWHERE branch is taken whenever the participant is Manager McTest, regardless of whether the receipt flag is still present — effectively aligning the optimistic side with theisDemoTransactionParamrule already used for the API call. This is a wider blast radius (every Manager McTest expense path is affected, including non-scan ones) and feels closer to a behavioral redesign than a bug fix, so the surgical preserve-on-edit approach above is preferable for this issue.46 remaining items
trjExpensify commentedon Jun 2, 2026
But we knowingly introduced a regression as a result of the change, so shouldn't the FE PR have been placed on hold for a BE PR to come first to avoid that? CC: @roryabraham as you were the internal reviewer on the PR.
melvin-bot commentedon Jun 5, 2026
@mallenexpensify Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
mallenexpensify commentedon Jun 9, 2026
@roryabraham 👀 above please. I think it would have been better to place this on hold but.. it's water under the bridge now and the regression wasn't unexpected so I think it's likely best to pay both @mkhutornyi and @samarroy84 $250 and move on (assuming it's ready to be closed, I'm not well-versed in everything here)
roryabraham commentedon Jun 9, 2026
@mallenexpensify I agree. The regression was flagged before merge so I think it's best to pay both @mkhutornyi and @samarroy84 $250
mallenexpensify commentedon Jun 9, 2026
Payment summary updated above.
@samarroy84 can you please accept the job below? Please reply here and tag me once you have.
https://www.upwork.com/jobs/~022061598602863514656
melvin-bot commentedon Jun 12, 2026
@samarroy84 Whoops! This issue is 2 days overdue. Let's get this updated quick!
melvin-bot commentedon Jun 16, 2026
@samarroy84 Still overdue 6 days?! Let's take care of this!
mallenexpensify commentedon Jun 17, 2026
@samarroy84 paid, summary updated above. Thx.
@samarroy84 please post on issues and tag me when you accept the job in Upwork, otherwise I won't know. Thx
trjExpensify commentedon Jun 23, 2026
approved $250 for @mkhutornyi