Repository navigation
Reuse the existing chat for a second expense to a login created offline - #103195
Conversation
…offline expense reuses the existing chat Co-authored-by: Maruf Sharifi <marufsharifi@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. |
|
🤖 Android test steps verification results: ❌ fail The second offline expense to a new login did not reuse the existing chat after the first expense synced. It created a separate chat with a "Hidden" participant and the errors "Unexpected error creating this chat" and "Unexpected error submitting this expense." The PR's Tests section is still a TODO, so I ran the reproduction steps from the linked issue on the PR head (c731bd2).
|
|
🤖 Web test steps verification results: I could not run the key condition on web: the second expense draft must stay open on its confirmation page while the app goes back online. The web test tooling cannot keep that draft open while switching back online, so I submitted a new draft started after going online instead. That second expense joined the existing chat, but a draft started online already has the real accountID, so this result does not prove the fix. The PR's Tests section is still a TODO, so I used the linked issue's steps on the PR head (c731bd2).
|
|
@MelvinBot, replace the PR Author checklist with the verified one below: PR author checklist |
|
I replaced the PR description with the verified version you shared. The Tests, Offline tests, QA Steps, and PR Author Checklist sections are now filled in and checked. Your version did not include the |
|
BUG: Sending a expense for a phoneNumber login shows unexpected error RF-1.mp4 |
|
@MelvinBot check this bug #103195 (comment) |
|
This PR likely causes the phone-number error. The new lookup by login misses phone recipients, because their login is saved without the Suggested fix: add the SMS suffix before the lookup in getPersonalDetailByEmail(addSMSDomainIfPhoneNumber(participant.login ?? ''))Add a unit test: a stale accountID with login How it breaks
Second gap: the FAB quick-action path builds participants with an accountID but no login. The lookup can't match those drafts for email or phone recipients, and the fresh-ID path fails the same way. This matches the earlier Android failure on this PR. Normalizing phone logins doesn't fix this path. Before merging, decide whether to find the real participant from the existing stored chat, or to rethink the fresh-ID change. Confidence: high on the client-side mechanism. I inferred the exact server rejection from an App code comment and the earlier Android run. I haven't confirmed it from the server. Web test on PR head (c731bd2)I couldn't view your video. My web test didn't show the "Unexpected error" text, but it did reproduce the "Hidden" recipient. The web test can't keep a draft open on the confirmation page while going back online. So I couldn't run the exact two-draft flow.
I didn't test whether |
|
@MelvinBot fix it. |
A phone number typed into the participant search is stored without the @expensify.sms domain, but the canonical account's login has it, so the lookup missed phone recipients and the draft kept its stale accountID. Co-authored-by: Maruf Sharifi <marufsharifi@users.noreply.github.com>
|
I pushed a fix for the phone-number error in e0816b9. I also added a unit test for a phone login without the SMS domain. Still open: the FAB quick-action path. Those drafts have an accountID but no login, so this lookup can't fix them. Please decide how you want to handle that before merging. Checks
|
Co-authored-by: Maruf Sharifi <marufsharifi@users.noreply.github.com>
|
Fixed the failing
|
|
@MelvinBot the app crash on RF.mov |
|
Bug: When a user sends an expense to an existing Expensify user and begins creating a second expense, the data syncs and the chat title loads, highlighting the corresponding chat in the LHN (Left-Hand Navigation). However, when the user sends the second expense, it is successfully sent to the correct chat, but the chat unexpectedly loses its highlighted (focused) state in the LHN. RF-1.webm |
|
@MelvinBot check this bug: #103195 (comment) |
|
I couldn't tie this bug to the PR's changes. Neither change affects which chat the LHN highlights or where the app navigates after you submit. I also couldn't reproduce it, because the automated web session got stuck on a blank page before it could start. The LHN highlights a chat when that chat is the report open in the main pane ( There are two possible causes. Neither is confirmed:
Two things would settle it:
view run · no recording available |
|
@MelvinBot, but it works on latest main. |
|
You're right. I was wrong that this PR can't affect navigation. The second change (the "taken ID" check) can send the expense to a new chat ID while the app still opens the old one, so the highlight is lost. Likely cause: the app picks two chat IDs separately from the same reserved ID (
The server then merges the fresh chat into the real chat, so the expense lands in the right place. But the app only moves the main pane to the real chat if the merged chat is the one on screen ( On Proposed fix: run the "taken ID" check once, on the confirmation page. If the reserved ID is taken and no chat matches, save a fresh ID to Confidence and open questionsMedium confidence. This comes from reading the code. I didn't reproduce it. Two things are still unconfirmed:
The main-pane URL before and after the second submit would confirm it. If this is the cause, it should stay on the old chat's Reply with |
|
@MelvinBot fix it. |
…ortID When the reserved chat ID already belonged to a stored report, the submission hooks built the new chat under a fresh ID while the confirmation screen still opened the reserved ID. The preexisting-chat redirect only follows the chat that is on screen, so the user stayed on a report with no LHN row and the chat lost its highlight. The stale-accountID fix in getParticipantsOption already lets the existing chat be found, so the reserved ID is reused again, matching main. Co-authored-by: Maruf Sharifi <marufsharifi@users.noreply.github.com>
|
I pushed a fix in The first change (resolving the stale accountID by login) stays. It's the part that lets the existing chat be found. Please retest the highlight case and the original test steps. Why I didn't use the fix I proposedI first tried what I proposed earlier: swapping in a fresh ID on the confirmation page. It broke two existing tests in The trade-off: the PR no longer has the extra guard against overwriting an existing chat if participant matching fails for some other reason. I also updated the PR description so it no longer mentions that change. Checks: |
|
@MelvinBot the original flow doesn't work now. carefully update to not break everything. 1.mov |
…o a stale optimistic accountID can be resolved Co-authored-by: Maruf Sharifi <marufsharifi@users.noreply.github.com>
|
@MelvinBot Merge the main. |
…PParticipantAccountID Co-authored-by: Maruf Sharifi <marufsharifi@users.noreply.github.com>
|
@MelvinBot resolve the conflicts. |
…PParticipantAccountID Co-authored-by: Maruf Sharifi <marufsharifi@users.noreply.github.com> # Conflicts: # src/hooks/useDefaultParticipants.ts
1a19fce
|
I merged The only conflict was in
Git merged the other files on its own. The |
|
@MelvinBot Merge the main. |
…PParticipantAccountID Co-authored-by: Maruf Sharifi <marufsharifi@users.noreply.github.com>
|
@MelvinBot Resolve the conflicts |
…PParticipantAccountID # Conflicts: # src/libs/actions/IOU/MoneyRequest.ts # src/pages/iou/request/step/IOURequestStepConfirmation/index.tsx # tests/actions/IOU/MoneyRequestSettersTest.ts
|
Resolved the merge conflicts with All three conflicts were import lists where both sides added names. I kept both sides:
|
|
doing another round of test. |
|
@garrettmknight all yours |
|
LGTM |
|
@garrettmknight, could you please take a look at this pr when you get a chance. thanks. |
|
Still looks good, merge away! |
|
🚧 carlosmiceli 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/carlosmiceli in version: 9.5.31-0 🚀
|
|
🚀 Deployed to staging by https://github.com/carlosmiceli in version: 9.5.31-0 🚀
|
|
No help site update needed — this PR restores expected expense and recipient behavior after offline syncing without changing documented workflows. |
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.5.31-4 🚀
Bundle Size Analysis (Sentry): |




















Explanation of Change
When you send an expense offline to a brand-new login, the app gives that login a temporary accountID. Once the request syncs, the temporary accountID is removed from personal details. A second expense draft that was started before the sync still holds the old ID. The confirmation page then couldn't match the existing chat, so it treated the recipient as brand new and reused the existing chat's ID as a "new" chat. The new chat is written with
Onyx.SET, which wiped the real chat locally and left a loading chat.This PR:
getParticipantsOption: when a participant's accountID is no longer in personal details, look the participant up by login and use the real account. The confirmation page and the submission hooks then find the existing chat, and the expense is added to it.getMoneyRequestDraftParticipantsFromReport: when a draft gets its recipient from a chat, store the recipient's login along with their accountID. For a recipient created offline, also store the reportID of their 1:1 chat, the same way a recipient picked from the participant list already has it. This coverssetMoneyRequestParticipantsFromReport,setMultipleMoneyRequestParticipantsFromReport(multi-scan) anduseDefaultParticipants, which fills in the recipient when you use the FAB quick action. Those drafts used to hold only the accountID, so the lookups in items 1 and 3 had nothing to use and the existing chat was still overwritten.getSyncedParticipantAccountIDs/setMoneyRequestParticipantsSyncedAccountIDs: the confirmation page now moves the draft itself to the real accountID once the recipient syncs, together with the recipient's split share. It finds the real account by login, or through the 1:1 chat when the server returns an existing Expensify user without a login. The chat is only used when the draft saved it as the recipient's chat, so a newly picked recipient is never swapped. Everything it needs is saved in the draft, so it also works when the sync finished before the confirmation page opened. Before this, the split share stayed saved under the old accountID and went blank, and an existing user's second expense still overwrote the chat.Fixed Issues
$ #102476
PROPOSAL: #102476 (comment)
Tests
While offline, use the main FAB to submit an expense to a new login that you have not previously chatted with.
Using the same login, start again from the main FAB and navigate to the confirmation page. Then, reconnect to the internet.
Submit a second expense.
Verify that the second expense is submitted to the same, correct chat report that was created for that login in Step 1, once the report has been created and synced.
Offline tests
N/A
QA Steps
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