Fix: distance expense to new user lands on Workspace with 'previously existing chat' error (new manual expense flow)#94755
Draft
MelvinBot wants to merge 1 commit into
Draft
Conversation
Co-authored-by: thelullabyy <thelullabyy@users.noreply.github.com>
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation of Change
This fixes a real bug in the new manual expense flow (
NEW_MANUAL_EXPENSE_FLOWbeta): submitting a Track-distance expense from global-create to a brand‑new user (no existing chat) navigated to a Workspace and showed the backend error "There is a previously existing chat between these users." instead of opening the chat with the new user.Root cause: On the global‑create Track‑distance flow, the distance navigation auto‑assigns the user's default expense policy and lands on the confirmation page with
route.params.reportIDset to the Workspace policy‑expense chat. When the user then changes the participant to a brand‑new user via the new‑flow inline participant picker,handleParticipantsAddedre‑binds the transaction's report usingfirstParticipant?.reportID ?? reportID. A brand‑new user has no existing chat, sofirstParticipant?.reportIDisundefinedand the fallback resolves to the routereportID(the Workspace chat). The submission then carries a participant/report mismatch — the new user as participant but the Workspace as the report — which collides with an existing report and produces the "previously existing chat" error, landing on the Workspace.Fix: In
IOURequestStepConfirmation.tsx, generate a fresh optimisticreportIDfor a participant that has no existing report instead of falling back to the route (Workspace)reportID. This mirrors the already‑correct participant‑step behavior inuseParticipantSubmission.ts:282(firstParticipantReportID || generateReportID()). The now‑unusedreportIDdependency was removed from the callback's dependency array.The change is surgical: it only affects how the report is bound when the user explicitly picks a participant with no existing chat. The self‑DM branch and the default‑participant auto‑assignment are untouched.
Fixed Issues
$ #94289
PROPOSAL: #94289 (comment)
Tests
NEW_MANUAL_EXPENSE_FLOWbeta, and use an account that has an auto‑reporting default expense policy (Workspace).Automated tests run locally by the co-author:
npm test -- tests/ui/components/IOURequestStepConfirmationPageTest.tsx→ 13 passednpm test -- tests/ui/components/IOURequestStepDistanceTest.tsx→ 1 passednpm run typecheck-tsgo,npm run lint-changed,npm run prettier, andreact-compiler-compliance-check(no regression) all pass.Verify that no errors appear in the JS console
Offline tests
Same as Tests.
QA Steps
NEW_MANUAL_EXPENSE_FLOWbeta on a Workspace account with an auto‑reporting default policy.PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)Avatar, 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