Don't fire duplicate ReconnectApp on delegate account switch#89262
Conversation
|
@abzokhattab 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] |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
|
@abzokhattab can you please prioritize the review? |
There was a problem hiding this comment.
Pull request overview
Reduces unnecessary network traffic when switching accounts via delegate access by preventing an immediately-following full reconnect from being triggered right after OpenApp, avoiding redundant sync work.
Changes:
- Introduces
clearOnyxForDelegateTransition()to seedLAST_FULL_RECONNECT_TIMEbefore clearing Onyx during delegate transitions. - Replaces direct
Onyx.clear(KEYS_TO_PRESERVE_DELEGATE_ACCESS)calls withclearOnyxForDelegateTransition()in delegate connect/disconnect/restore flows. - Updates the OldDot→NewDot delegate-switch transition flow to use the new clear helper.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/libs/actions/Session/index.ts | Uses the new delegate-transition Onyx clear helper during OldDot account switching to avoid triggering redundant reconnect behavior. |
| src/libs/actions/Delegate.ts | Adds and exports clearOnyxForDelegateTransition() and switches existing delegate flows to use it. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * duplicate ReconnectApp on top of the OpenApp that follows the transition. Seeding | ||
| * it to `now` short-circuits the subscriber until OpenApp's successData refreshes it. | ||
| */ | ||
| function clearOnyxForDelegateTransition(): Promise<void> { |
|
lets add a test for the |
|
Nice perf win for the delegate transition. One observation worth flagging (not blocking): the same
In each, after the clear i think a good approach is to is to generalize the helper (e.g. |
|
@MelvinBot can you please create a dedicated issue for this pull request and assign @mountiny and @TMisiukiewicz and @abzokhattab. Make it with Daily, Bug, Reviewing labels |
|
Lets add a test and push this ahead - if no regressions are found we can generalize it for the other flows too, what do you think? |
|
Created a dedicated issue for this PR: #89271 Assigned to |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2026-04-30.at.18.05.24.movAndroid: mWeb ChromeScreen.Recording.2026-04-30.at.18.04.33.moviOS: HybridAppScreen.Recording.2026-04-30.at.18.05.24.moviOS: mWeb SafariScreen.Recording.2026-04-30.at.18.04.33.movMacOS: Chrome / SafariScreen.Recording.2026-04-30.at.18.02.24.mov |
|
LGTM 🚀🚀 |
|
No product review needed |
|
@TMisiukiewicz conflicts |
…ll-reconnect-time-on-delegate-switch # Conflicts: # src/libs/actions/Delegate.ts
|
@mountiny done ✅ |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 @mountiny 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/mountiny in version: 9.3.66-0 🚀
|
|
No help site changes are required for this PR. The changes are an internal performance optimization that prevents a duplicate |
Explanation of Change
When a user switches accounts via delegate access, the app sends
OpenAppand then an unnecessaryReconnectAppright after. This PR removes that extra request. The two are not duplicates — they hit different endpoints — but the second one is wasted work because OpenApp has already brought down the freshest data.It's safe because no real sync is skipped. The
OpenAppwe just sent IS a full sync. The safety net's job is "you might be stale, refresh." AfterOpenAppyou're not stale. Skipping the immediately-followingReconnectAppdoesn't lose any data.Fixed Issues
$ #89271
PROPOSAL:
Tests
ReconnectAppis not called afterOpenAppOffline tests
N/A
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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari