Skip to content

perf: defer central report list on Inbox tab navigation#96374

Draft
BartekObudzinski wants to merge 5 commits into
Expensify:mainfrom
callstack-internal:perf/inbox-tab-defer-central-report
Draft

perf: defer central report list on Inbox tab navigation#96374
BartekObudzinski wants to merge 5 commits into
Expensify:mainfrom
callstack-internal:perf/inbox-tab-defer-central-report

Conversation

@BartekObudzinski

@BartekObudzinski BartekObudzinski commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

On wide layout, tapping the Inbox tab navigates to the last opened report. The current URL-based navigation rebuilds the nested report route, so React remounts the central ReportScreen and its heavy report actions list in the same commit as the LHN. The ManualNavigateToInboxTab span ends when the LHN lays out, but that layout cannot paint until the report list commit finishes.

This PR follows the cached navigation architecture used by the Search and Spend tab:

  1. When a valid Reports tab state already exists, the Inbox tab focuses it with a targeted TabActions.jumpTo action. Omitting nested params preserves the mounted ReportScreen, report list, route key, report params, and URL.
  2. The first warm Inbox mount still defers ReportActions behind NavigationDeferredMount, allowing the LHN to paint before the heavy list hydrates.
  3. The deferred mount now lives in the stable ReportScreen slot. After the first hydration, react-freeze preserves that state. Subsequent Home to Inbox navigations reuse the same report list and do not show the skeleton again.
  4. Cold navigation, deleted reports, deleted report actions, and uninitialized Reports navigators keep the existing URL-based fallback.

The deferral remains scoped to an in-flight ManualNavigateToInboxTab span. Opening a report from the LHN, a deep link, or Search does not start that span and renders the report immediately.

Benchmark results

Wide web with warm cached data.

First warm Inbox mount, 8 measured runs:

Metric Before After Improvement
P90 793 ms 518 ms 34.7%
Average 703 ms 494 ms 29.7%

Subsequent cached Inbox visits, 12 measured runs:

Metric Before After Improvement
P90 344 ms 72 ms 79.1%
Average 315 ms 67 ms 78.7%

The skeleton appears only during the first mount. Subsequent Home to Inbox navigations preserve the same ReportScreen and report list with no skeleton.

Fixed Issues

$ #96398
PROPOSAL:

Tests

  1. Open the app on a wide screen and navigate to Home.
  2. Refresh the page, then tap Inbox.
  3. Verify the central report shows a loading skeleton once and then the full cached report content.
  4. Navigate to Home and tap Inbox again.
  5. Verify the same report appears immediately without another skeleton.
  6. Repeat the Home to Inbox navigation and verify the report URL remains /r/:reportID.
  7. Use browser back and forward and verify Home and the same Inbox report are restored.
  8. Open another report from the LHN and through a deep link. Verify both render without the Inbox tab defer skeleton.
  9. Verify that no errors appear in the JS console.
  • Verify that no errors appear in the JS console

Offline tests

  1. Go offline after visiting an Inbox report once.
  2. Navigate to Home and then back to Inbox on a wide screen.
  3. Verify the cached report is restored immediately without another skeleton.
  4. Refresh on Home while offline, then open Inbox.
  5. Verify the expected offline report state renders without errors.

QA Steps

  1. On a wide screen, open Inbox once and wait for the report content.
  2. Switch between Home and Inbox several times.
  3. Verify the first Inbox mount may show a short skeleton, while subsequent visits show the cached report immediately without a skeleton.
  4. Verify the last report, report URL, browser back, and browser forward behavior remain correct.
  5. Verify opening reports from the LHN and deep links behaves normally.
  6. Verify there are no console errors or visual regressions.
  • 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

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/CONST/index.ts 94.81% <ø> (ø)
.../NavigationTabBar/getReusableReportsTabStateKey.ts 100.00% <100.00%> (ø)
...nts/Navigation/NavigationTabBar/InboxTabButton.tsx 25.31% <0.00%> (-1.00%) ⬇️
src/pages/inbox/ReportScreen.tsx 88.46% <55.55%> (-7.00%) ⬇️
... and 39 files with indirect coverage changes

@BartekObudzinski
BartekObudzinski force-pushed the perf/inbox-tab-defer-central-report branch 2 times, most recently from 3948493 to 2e7566c Compare July 17, 2026 13:20
@BartekObudzinski
BartekObudzinski force-pushed the perf/inbox-tab-defer-central-report branch from 2e7566c to 727d764 Compare July 17, 2026 13:27
}

return (
<NavigationDeferredMount

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.

@BartekObudzinski Let's put ReportActionsWithInboxTabDeferredMount into src/pages/inbox/ReportActions.tsx

@DylanDylann

Copy link
Copy Markdown
Contributor

@BartekObudzinski I love the idea. The transition is now smoother since we no longer perform the navigate function. I also noticed that the change fixes some flickers during the transition that happen when using the navigate function

Screen.Recording.2026-07-18.at.17.37.25.mov

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