Skip to content

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

Open
neerajbachani wants to merge 2 commits into
Expensify:mainfrom
neerajbachani:fix/97159-duplicate-openapp-deep-link
Open

Fix duplicate OpenApp on deep link by recording full reconnect time immediately#100547
neerajbachani wants to merge 2 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
  2. Verify all 34 tests pass, including the new boot-state regression test that asserts only one OpenApp fires when the cutoff arrives while the first response is still queued.
  3. Open Chrome in an incognito window and sign in to staging New Expensify.
  4. While signed in, open an OldDot report link in the format https://www.expensify.com/report?param={"pageReportID":"<reportID>"} (or use the transition link from the issue).
  5. Confirm the app routes through /transition and lands on /search/r/<reportID>.
  6. Confirm the report loads fully instead of staying on a semi-transparent skeleton with Home visible behind it.
  7. Open https://staging.new.expensify.com/search/r/<reportID> directly (no /transition hop) and confirm the report still loads normally.
  8. 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

  1. Sign in to staging New Expensify in a fresh browser session (incognito recommended).
  2. Open an OldDot report link while already signed in, e.g. https://www.expensify.com/report?param={"pageReportID":"<reportID>"}.
  3. Confirm the app navigates through /transition?...&exitTo=search/r/<reportID> and opens the report in the RHP.
  4. Confirm the report content loads (transactions/actions visible) and the semi-transparent skeleton does not get stuck indefinitely.
  5. Confirm Home is not permanently visible behind a stuck loading overlay once loading completes.
  6. Repeat with a direct link to https://staging.new.expensify.com/search/r/<reportID> and confirm the report still opens normally.
  7. Verify that no errors appear in the JS console.

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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
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
@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 OpenApp, and with this fix it passes with 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 on lines 61 to +62
*
* The entry goes right before the delivered cutoff entry, so the reconnect subscription never sees
* a new cutoff next to an old reconnect time. That assumes Onyx broadcasts a batch's merges in
* array order: true today because both keys are cache-resident (see subscribeToFullReconnect.ts),
* and pinned by the SubscribeToFullReconnect e2e test. If it ever broke, the worst case is one
* transient extra reconnect, never a loop.
* The time is written directly to Onyx (not spliced into the deferred response batch) so

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.

(not spliced into the deferred response batch)

Is there a reason to mention an approach that will no longer exist after this PR?

Comment on lines +69 to +70
// Written directly to Onyx (not via an action) so subscribeToFullReconnect observes LAST_FULL_RECONNECT_TIME before any cutoff from the same response can land.
// eslint-disable-next-line rulesdir/prefer-actions-set-data

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.

The comment doesn't explain why you suppress the rule instead of following it. I don't see a reason either.

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.

2 participants