Fix iOS freeze when picking a brand-new P2P recipient on the distance confirmation step#95771
Fix iOS freeze when picking a brand-new P2P recipient on the distance confirmation step#95771MelvinBot wants to merge 2 commits into
Conversation
…ipient Co-authored-by: thelullabyy <thelullabyy@users.noreply.github.com>
…ChatReportID Co-authored-by: thelullabyy <thelullabyy@users.noreply.github.com>
|
I created this PR from an upstream branch since I don't have push access to your fork. To take ownership of this branch and be able to push updates, run: Then you can close this PR and open a new one from your fork. |
|
🤖 I looked into the failing checks. No code fix is needed — the only failing check is Every substantive CI check passed:
The Note on the remaining pending checksAt the time of this analysis, |
|
@MelvinBot Please replace all |
|
@DylanDylann 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] |
|
🤖 Done,
|
|
@codex review |
|
@DylanDylann Please ignore this PR. This is fixed PR for my PR's regression. I will review it |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Explanation of Change
On iOS, starting a Track distance expense and then picking a brand‑new recipient (an email you have no existing chat with) on the confirmation step froze the app instead of landing in the new chat.
This is a regression from #94755, which fixed the older "There is a previously existing chat between these users." error on the same flow. To avoid binding the expense to the auto‑assigned workspace chat,
handleParticipantsAddednow writes a freshly generated optimisticreportID(call it A) onto the draft transaction for a brand‑new P2P recipient. The problem is that this ID was never handed to the submit action, so on submitcreateDistanceRequest→getMoneyRequestInformationbuilt the optimistic chat report at a different generated ID (B). The confirmation screen was left subscribed to report A, which never materialized (the real chat was created at B), so the screen hangs waiting on a report that never loads.The fix keeps the generated
reportIDcoherent end‑to‑end — the same contract the legacy participants‑step flow (useParticipantSubmission) already honors. When the confirmation page has committed the draft transaction to a fresh optimisticreportIDfor a brand‑new P2P recipient, that same ID is now threaded into the distance‑create submission as the optimistic chat report ID, so the optimistic chat report is actually created at the ID the page is subscribed to. That collapses the A‑vs‑B mismatch: the screen's report resolves and navigation lands on the real new‑user chat.Changes:
src/pages/iou/request/step/confirmation/useExpenseSubmission.ts— increateDistanceRequest, for the narrow brand‑new P2P case (no resolvablereport, participant is not a policy expense chat, participant has no existingreportID, andtransaction.reportIDis a real generated ID rather thanUNREPORTED_REPORT_ID), passtransaction.reportIDasoptimisticChatReportID.src/libs/actions/IOU/Split.ts— extendCreateDistanceRequestInformation/createDistanceRequestto accept an optionaloptimisticChatReportIDand thread it intogetMoneyRequestInformation, which already honors it when building a new optimistic chat report. Existing chats, policy expense chats, self‑DM/track fallback, and split flows are unaffected (they carry a realreportID, so the new value isundefined).tests/actions/IOUTest/SplitTest.ts— regression test assertingcreateDistanceRequestbuilds the optimistic chat at the providedoptimisticChatReportID.This implements the approved proposal.
Fixed Issues
$ #95468
PROPOSAL: #95468 (comment)
Tests
// TODO: The human co-author must fill out the tests you ran before marking this PR as "ready for review".
// Please describe what tests you performed that validates your changes worked.
Suggested manual test:
Offline tests
Same as Tests — the optimistic chat report is created at the same ID before the API round‑trip, so the expense should appear in the new chat while offline.
QA Steps
// TODO: The human co-author must fill out the QA tests you ran before marking this PR as "ready for review".
Same as Tests.
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