Clear stale iouReportID on DM chat after IOU is moved to a new workspace#89551
Conversation
…ce via pay-with-business-account cancel flow
…stale-iou-report-id-on-dm-after-pay-to-workspace
…stale-iou-report-id-on-dm-after-pay-to-workspace
|
@jayeshmangwani in account B, can you see "Pay with bank account" option? mine only show "Mark as Paid" |
|
@cristipaval @jayeshmangwani this PR's optimistic clear works for the receiver (the one tapping "Pay with business account"), but the bug still reproduces from the sender's side because the move event pushed to the sender doesn't I verified locally: manually merging {iouReportID: null} into the sender's DM and then submitting a fresh expense correctly routes it to a brand-new IOU report. Could the BE include iouReportID: null in the CreateWorkspaceFromIOUPayment response's onyxData — specifically on the old DM chat report (the one whose IOU just got moved to the new workspace), so the cleared |
|
hey @wildan-m, yes, it makes a lot of sense to clear out that |
|
@cristipaval any updates? |
Hmm.. it looks like the backend PR is still awaiting review. I'll bump the internal engineer |
|
Hey @wildan-m, the backend fix has been deployed. |
…stale-iou-report-id-on-dm-after-pay-to-workspace
|
@jayeshmangwani 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] |
|
@cristipaval works fine, thanks! |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid-1.movAndroid: mWeb Chromemweb-chrome-1.moviOS: HybridAppiOS-1.moviOS: mWeb Safarimweb-safari-1.movMacOS: Chrome / Safariweb-1.mov |
|
@cristipaval looks like this was merged without a test passing. Please add a note explaining why this was done and remove the |
|
it was all green |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 @cristipaval has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/cristipaval in version: 9.3.80-0 🚀
Bundle Size Analysis (Sentry): |
|
No help site changes required. This PR is a bug fix that clears a stale |
|
🚀 Deployed to production by https://github.com/luacmartins in version: 9.3.81-2 🚀
|
Explanation of Change
In a 1:1 DM, when the recipient taps "Pay with business account" on a manual expense and cancels the bank-account setup,
createWorkspaceFromIOUPaymentinsrc/libs/actions/Policy/Policy.tsoptimistically converts the IOU report into an Expense report under a new workspace and updates the old DM chat in three ways: it nullifies the oldREPORT_PREVIEW, setshasOutstandingChildRequest: false, and appends aMOVEDaction.It never clears
chatReport.iouReportIDon the DM, so the field still points at the report that has just been moved to a different policy. When the sender then creates another expense in the same DM,getMoneyRequestInformationresolves the moved report viachatReport.iouReportID,shouldCreateNewMoneyRequestReportreuses it because it is stillOPEN, and the moved expense "comes back" to the DM preview alongside the new transaction. Opening the preview shows a header from the new workspace's policy, and the newly created expense errors out because the participants/policy no longer match.This PR extends the optimistic merge on the old DM chat to also clear
iouReportID: null, and mirrors the rollback in the failure entry by restoring the prioriouReportID. With the pointer cleared,getMoneyRequestInformationno longer resolves the moved report from the DM, so a fresh IOU report is built for the next expense and the duplicate preview / mismatched header / new-transaction error all disappear.This mirrors the precedent already set by other flows that remove an IOU report from a DM:
src/libs/actions/IOU/PayMoneyRequest.tsclearsiouReportIDon payment success.submitReportinsrc/libs/actions/IOU/index.tsclears it when a report is submitted to a workspace.DeleteMoneyRequest.tsclears it when the last transaction on a DM's IOU report is deleted.createWorkspaceFromIOUPaymentwas simply missing the equivalent step. The change is scoped entirely to the optimistic/failureonyxDatabuilt inside that function — its only caller issrc/components/KYCWall/BaseKYCWall.tsx, which is unaffected.Fixed Issues
$ #81636
PROPOSAL: #81636 (comment)
Tests
Test data setup:
Steps:
Offline tests
QA Steps
Same as tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, 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.ScrollViewcomponent to make it scrollable when more elements are added to the page.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
Kapture.2026-05-15.at.06.53.17.mp4
Android: mWeb Chrome
Kapture.2026-05-15.at.06.56.57.mp4
iOS: Native
Kapture.2026-05-15.at.06.13.36.mp4
iOS: mWeb Safari
Kapture.2026-05-15.at.06.33.52_compressed.mp4
MacOS: Chrome / Safari
Kapture.2026-05-15.at.06.02.44.mp4