Skip to content

Fix duplicate OpenApp on deep link by recording full reconnect time immediately - #100547

Merged
danieldoglas merged 3 commits into
Expensify:mainfrom
neerajbachani:fix/97159-duplicate-openapp-deep-link
Sep 14, 2026
Merged

danieldoglas merged 3 commits into
Expensify:mainfrom
neerajbachani:fix/97159-duplicate-openapp-deep-link

Conversation

@neerajbachani

@neerajbachani neerajbachani commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

When opening a report via an OldDot /transition deep link, subscribeToFullReconnect could fire an unnecessary ReconnectApp during boot because LAST_FULL_RECONNECT_TIME was spliced into the deferred OpenApp response batch. The cutoff became visible in Onyx before the recorded reconnect time, so reconnectApp() fell back to a second OpenApp, leaving the report stuck on a semi-transparent skeleton.

This PR removes the broken splice in recordFullReconnectTimeFromResponse and writes LAST_FULL_RECONNECT_TIME directly to Onyx inside the RecordFullReconnectTime middleware, awaited before SaveResponseInOnyx can stage the cutoff. That prevents the duplicate full download without adding a hasLoadedApp guard around the reconnect subscription.

Fixed Issues

$ #97159
PROPOSAL: #97159 (comment)

Tests

  1. Run unit tests:
    • npm test -- tests/unit/SubscribeToFullReconnectTest.ts tests/unit/FullReconnectUtilsTest.ts tests/unit/RecordFullReconnectTimeMiddlewareTest.ts tests/actions/RecordFullReconnectTimeFromResponseTest.ts
  2. Verify all tests pass, including the fresh-boot regression test that asserts only one OpenApp fires when the cutoff arrives while the first response is still queued.
  3. In a signed-in browser, open an OldDot report link, e.g. https://www.expensify.com/report?param={"pageReportID":"<reportID>"}.
  4. As soon as it redirects to new.expensify.com/transition?...&exitTo=search/r/<reportID>, quickly copy the full URL and close the tab.
  5. Open a fresh incognito window, paste the copied URL, and change the host to dev.new.expensify.com:8082.
  6. Confirm the app lands on /search/r/<reportID> and the report loads with a brief opaque loader (not a stuck semi-transparent skeleton with Home visible behind it).
  7. Verify that no errors appear in the JS console.

Offline tests

N/A — this change affects the OpenApp/reconnect ordering during initial app load over the network. No offline-specific behavior was changed.

QA Steps

Same flow as Tests, only the host changes:

  1. Open https://www.expensify.com/report?param={"pageReportID":""} while signed in.
  2. As soon as it redirects to new.expensify.com/transition..., copy the URL and close the tab.
  3. Open a new incognito window, paste the URL, and change new.expensify.com to staging.new.expensify.com.
  4. Confirm the loader is brief and fully opaque, then goes away, and the report loads on /search/r/.

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native (N/A)
Android: mWeb Chrome
lv_0_20260911005410.mp4
iOS: Native (N/A)
iOS: mWeb Safari
Screen.Recording.2026-09-10.at.11.13.33.PM.mov
MacOS: Chrome / Safari
Screen.Recording.2026-09-09.at.10.17.19.AM.online-video-cutter.com.mp4

@neerajbachani
neerajbachani marked this pull request as ready for review September 9, 2026 03:56
@neerajbachani
neerajbachani requested review from a team as code owners September 9, 2026 03:56
@melvin-bot
melvin-bot Bot requested review from QichenZhu and garrettmknight and removed request for a team and garrettmknight September 9, 2026 03:56
@melvin-bot

melvin-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown

@QichenZhu 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]

@melvin-bot
melvin-bot Bot removed the request for review from a team September 9, 2026 03:56
Comment thread src/libs/FullReconnectUtils.ts Resolved
@neerajbachani

Copy link
Copy Markdown
Contributor Author

Hey @QichenZhu , Could you please run an adhoc build on this branch for QA?

I tried to manually test the /transition → /search/r/ flow locally, but dev doesn’t support the OldDot report link path (www.expensify.com/report?param=...), so I can’t reliably reproduce or verify the fix on dev.new.expensify.com. Staging with an adhoc from this branch would be the most accurate way to QA the real handoff.

Automated coverage: I added unit tests on this branch that model the boot race - on main the test fails with 2× OpenApp, and with this fix it passes with 1× OpenApp (SubscribeToFullReconnectTest fresh-boot case, plus updated FullReconnectUtilsTest / RecordFullReconnectTimeMiddlewareTest).

Thanks!

@QichenZhu

Copy link
Copy Markdown
Contributor

@neerajbachani, you can open
www.expensify.com/report?param=..., and as soon as it redirects to new.expensify.com/transition..., quickly copy the URL and close the tab. Then open an incognito window, paste the URL, and change new.expensify.com to dev.new.expensify.com:8082.

You need to do the same even with ad hoc builds, so I'd suggest testing locally and finishing the checklist first.

@neerajbachani

Copy link
Copy Markdown
Contributor Author

Thanks @QichenZhu that works!

I tested the /transition flow locally a few times using the copied URL on dev.new.expensify.com:8082, and I’m getting the expected result each time: the loader is brief, fully opaque, and goes away, and the real report loads on /search/r/<reportID>.

Here’s a video of one of the runs:

Screen.Recording.2026-09-09.at.10.17.19.AM.online-video-cutter.com.mp4

I’m working through the rest of the PR checklist now as well. Thanks again!

Comment thread src/libs/FullReconnectUtils.ts Resolved
Comment thread src/libs/FullReconnectUtils.ts Resolved
@QichenZhu

Copy link
Copy Markdown
Contributor

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp (N/A)

The test steps don't support native platforms.

Android: mWeb Chrome
android-web.webm
iOS: HybridApp (N/A)

The test steps don't support native platforms.

iOS: mWeb Safari
ios-web.mov
MacOS: Chrome / Safari
mac-web.mov

@QichenZhu QichenZhu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neerajbachani, the changes look good to me.

Three issues about the test steps:

  1. The test steps don't match your recording. Please don't copy AI's steps if AI didn't run them itself, as the steps may not make sense. Please update them according to #100547 (comment).
  2. Please also update the QA steps similar to the Tests. Just change dev.new.expensify.com:8082 to staging.new.expensify.com, since the QA team can't access the dev environment.
  3. Please upload recordings for Android mWeb and iOS mWeb. The steps don't apply to native platforms, so you can skip Android Native and iOS Native.

@melvin-bot
melvin-bot Bot requested a review from danieldoglas September 10, 2026 12:19
@neerajbachani

Copy link
Copy Markdown
Contributor Author

@QichenZhu TYSM for the guidance, working on it!!

@neerajbachani

Copy link
Copy Markdown
Contributor Author

@neerajbachani, the changes look good to me.

Three issues about the test steps:

  1. The test steps don't match your recording. Please don't copy AI's steps if AI didn't run them itself, as the steps may not make sense. Please update them according to #100547 (comment).
  2. Please also update the QA steps similar to the Tests. Just change dev.new.expensify.com:8082 to staging.new.expensify.com, since the QA team can't access the dev environment.
  3. Please upload recordings for Android mWeb and iOS mWeb. The steps don't apply to native platforms, so you can skip Android Native and iOS Native.

Hey @danieldoglas, I've addressed all three points flagged above; Would appreciate a look whenever you get a chance. Thanks!

@danieldoglas
danieldoglas merged commit 093cdbc into Expensify:main Sep 14, 2026
38 of 44 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 danieldoglas has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/danieldoglas in version: 9.4.78-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

MelvinBot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

🤖 No help site changes are required for this PR — so no draft PR was created.

This PR is an internal networking/ordering fix. It changes when LAST_FULL_RECONNECT_TIME is written to Onyx so a deep-link boot doesn't fire a second OpenApp. It adds no feature, no setting, no UI label, and no user-facing copy.

Changed file User-facing?
src/libs/FullReconnectUtils.ts No — removes an internal helper
src/libs/Middleware/RecordFullReconnectTime.ts No — awaits the Onyx write
src/libs/actions/recordFullReconnectTimeFromResponse.ts No — new internal action
4 test files No
How I checked the help site

I searched docs/articles for the concepts this PR touches — deep links, the OldDot /transition flow, reconnect/OpenApp behavior, and loading skeletons. Nothing in the help site documents them.

The only near-match, docs/articles/new-expensify/settings/General-product-troubleshooting.md, covers generic "page not loading → clear your cache" advice. It makes no claim about deep-link loading behavior, so it stays accurate either way.

The only observable difference for a user is that a report opened from an Expensify Classic report link shows a brief opaque loader instead of a stuck skeleton. That's a bug being fixed, not documented behavior — the help site never described the broken state, so there is nothing to correct.

Per docs/HELP_AUTHORING_GUIDELINES.md, help articles describe what a customer does in the product. There is no customer-facing action here.

neerajbachani — there's no linked help site PR to review, since this change doesn't affect any article. If you think a specific article does need updating, reply with the article and what's now wrong and I'll draft the PR.


view run · no recording available

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/luacmartins in version: 9.4.78-3 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants