Skip to content

Expense - Report RHP re-renders every time clicking Create expense #85155

Closed

Description

@lanitochka17

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Version Number: 9.3.37-0
Reproducible in staging?: Yes
Reproducible in production?: No
If this was caught during regression testing, add the test name, ID and link from BrowserStack: #82764
Email or phone of affected tester (no customers): biruknew45+yh6g@gmail.com
Issue reported by: Applause Internal Team
Bug source: Exploratory - Significant User Experience Deterioration
Device used: Web
App Component: Money Requests

Action Performed:

Precondition -
Have a report with a couple of expenses(at least two)

  1. Go to https://staging.new.expensify.com/
  2. Go to the workspace chat
  3. Open the expenses Preview
  4. Click on "+" > Create Expense

Expected Result:

The report RHP should remain stable when clicking Create expense

Actual Result:

Clicking on Create expense triggers a re-render of the report RHP

Workaround:

Unknown

Platforms:

  • Android: App
  • Android: mWeb Chrome
  • iOS: App
  • iOS: mWeb Safari
  • iOS: mWeb Chrome
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Bug7101658_1773359247469.bandicam_2026-03-13_02-45-46-516.mp4

View all open jobs on GitHub

Issue OwnerCurrent Issue Owner: @GCyganek

Activity

  1. added
    DeployBlockerCash
    Daily
    Bug
    on Mar 13, 2026
  2. melvin-bot commented on Mar 13, 2026

    @melvin-bot

    You have been assigned to this deploy blocker because you recently merged this PR: #82764

  3. melvin-bot commented on Mar 13, 2026

    @melvin-bot

    💬 A slack conversation has been started in #expensify-open-source

  4. github-actions commented on Mar 13, 2026

    @github-actions
    Contributor

    👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:

    1. Identify the pull request that introduced this issue and revert it.
    2. Find someone who can quickly fix the issue.
    3. Fix the issue yourself.
  5. OSBotify commented on Mar 13, 2026

    @OSBotify
    Contributor

    🔍 Investigation Summary

    Classification: Frontend bug
    Causing PR: #82764 - "Freeze non top screens to prevent extra-rerenders" by @VickyStash (High confidence)
    Related Issues: #33725, #9402

    Recommendation: REVERT

    PR #82764 introduced screen freezing to prevent unnecessary re-renders of non-visible screens. However, this is causing the report RHP to re-render when clicking "Create expense" because the navigation triggers the freeze/unfreeze mechanism on the underlying screen.

    Labels: Keeping DeployBlockerCash (this blocks the App deploy). DeployBlocker was not present on this issue, so no label changes are needed.

    📋 Detailed Analysis

    Evidence

    Verification

    The causing PR modified:

    • src/libs/Navigation/AppNavigator/createSplitNavigator/index.tsx - Added freezeNonTopScreens: true
    • src/libs/Navigation/PlatformStackNavigation/createPlatformStackNavigatorComponent/index.tsx - Implemented screen freezing logic
    • src/libs/Navigation/PlatformStackNavigation/createPlatformStackNavigatorComponent/ScreenFreezeWrapper.tsx - New wrapper component for freezing

    These files directly control navigation and screen rendering behavior in the split navigator (used on web).

    Root Cause

    When the user clicks "Create expense" from the expense preview, the app navigates to a new screen. This causes the underlying report RHP to become "not on top" in the navigation stack. The screen freezing mechanism then:

    1. Detects the report RHP is no longer the top screen (isOnTop = false)
    2. Triggers the ScreenFreezeWrapper to freeze the screen
    3. The freeze/unfreeze transition causes the visible re-render that users are experiencing

    The issue occurs specifically on web because:

    • The split navigator (with freezeNonTopScreens: true) is used on web layouts
    • The RHP remains visible in the background while the new screen opens
    • The freeze state change triggers a render that is visually apparent to users
  6. MelvinBot commented on Mar 13, 2026

    @MelvinBot
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    When viewing a workspace chat report with expenses and clicking "+" > "Create Expense" from the expenses preview, the report RHP (central pane of the split navigator) visually re-renders/flickers. This was introduced by PR #82764 ("Freeze non top screens to prevent extra-rerenders") and is reproducible on staging but not production.

    What is the root cause of that problem?

    The root cause is that the wrappedDescriptors computation in src/libs/Navigation/PlatformStackNavigation/createPlatformStackNavigatorComponent/index.tsx:108-122 is not memoized. Every time the PlatformNavigator component re-renders, it creates a brand-new wrappedDescriptors object with new render() function closures — even when nothing meaningful has changed.

    Here's the chain of events:

    1. Clicking "Create expense" pushes the RightModalNavigator onto the root stack, changing the root navigation state.
    2. React Navigation's context propagation causes the ReportsSplitNavigator to re-render (even though the split navigator's own internal state hasn't changed).
    3. On re-render, the wrappedDescriptors block (lines 108-122) runs unconditionally, creating new descriptor objects with new render() closures wrapping each screen in ScreenFreezeWrapper.
    4. Since wrappedDescriptors is a new object reference every render, it invalidates the Content useMemo on line 124 (which depends on wrappedDescriptors).
    5. StackView receives new descriptors prop and re-renders all screens, including the report screen that the user sees — causing the visible flicker.

    Before PR #82764, wrappedDescriptors was simply descriptors (the original from useNavigationBuilder), which was a stable reference across renders. The Content useMemo worked correctly. After PR #82764, the wrapping code always creates fresh objects, breaking the memoization.

    What changes do you think we should make in order to solve the problem?

    Memoize the wrappedDescriptors computation in src/libs/Navigation/PlatformStackNavigation/createPlatformStackNavigatorComponent/index.tsx using useMemo, so it only produces a new object when the underlying inputs actually change (descriptors, state.index, state.routes, and persistentScreens).

    This ensures that when the split navigator re-renders due to unrelated navigation state changes (like opening the RHP), the wrapped descriptors remain referentially stable and the Content useMemo isn't needlessly invalidated.

    What alternative solutions did you explore? (Optional)

    1. Reverting freezeNonTopScreens for the split navigator — This would fix the bug but lose the performance benefit of freezing off-screen central pane screens that PR Freeze non top screens to prevent extra-rerenders #82764 was designed to provide.
    2. Wrapping the entire PlatformNavigator in React.memo — This wouldn't help because the re-render is triggered by internal hooks (useNavigationBuilder), not parent props.

    Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.

  7. situchan commented on Mar 13, 2026

    @situchan
    Contributor

    If this was caught during regression testing, add the test name, ID and link from BrowserStack: #82764

    @MelvinBot this doesn't mean that PR caused this regression. Can you re-investigate? There should be another PR which introduced this bug.

  8. situchan commented on Mar 13, 2026

    @situchan
    Contributor

    I managed to find offending PR

  9. MelvinBot commented on Mar 13, 2026

    @MelvinBot
    Contributor

    Thanks for the nudge, situchan. I understand the BrowserStack field just links the regression test PR, not necessarily the causing PR. I re-investigated all 50+ PRs in the v9.3.37-0 staging deploy and compared the production ↔ staging diffs for every file in the report rendering + navigation chain.

    What I checked

    I looked at every PR that touches IOU actions, report rendering, navigation, or Onyx-derived values — specifically:

    Why the evidence still points to PR #82764

    The only file changed between production and staging that could amplify an existing (invisible) re-render into a visible one is createPlatformStackNavigatorComponent/index.tsx (PR #82764). Here's the mechanism:

    1. Production: When the SplitNavigator re-renders (from navigation context or TRANSACTION_DRAFT changes), wrappedDescriptors is simply the stable descriptors reference from useNavigationBuilder. The Content useMemo (line 124) correctly prevents StackView from re-rendering.

    2. Staging: PR Freeze non top screens to prevent extra-rerenders #82764 added freezeNonTopScreens: true, which wraps descriptors at lines 108-122. This wrapping is not memoized — it creates new objects with new render() closures on every render. Since wrappedDescriptors is always a new reference, the Content useMemo is invalidated, and StackView re-renders all screens including the visible report — causing the flicker.

    The TRANSACTION_DRAFT writes from clearMoneyRequest acted as the trigger (causing the SplitNavigator to re-render), and the un-memoized wrappedDescriptors from PR #82764 is the amplifier (turning an invisible React re-render into a visible DOM update).

    If you have evidence the bug reproduces even after reverting PR #82764, I'm happy to investigate further. But based on the production ↔ staging comparison, PR #82764's un-memoized wrappedDescriptors is the only change that could convert existing re-renders into visible flicker.

  10. situchan commented on Mar 13, 2026

    @situchan
    Contributor

    false alarm ^
    @MelvinBot, for further investigations, make sure to check if component is compatible with React Compiler before finding un-memoization as root cause.

  11. situchan commented on Mar 13, 2026

    @situchan
    Contributor

    #85171 should fix this

  12. GCyganek commented on Mar 13, 2026

    @GCyganek
    Contributor

    Checking if there is a way to fix this without the revert...

  13. GCyganek commented on Mar 13, 2026

    @GCyganek
    Contributor

    My fix so that we do not have to revert

  14. added
    Reviewing
    on Mar 13, 2026
  15. IuliiaHerets commented on Mar 13, 2026

    @IuliiaHerets

    Chrome / v9.3.37-7
    Not reproduce

    Screen.Recording.2026-03-13.at.21.29.03.mp4
  16. luacmartins commented on Mar 13, 2026

    @luacmartins
    Contributor

    Fixed. Closing.

  17. removed
    DeployBlockerCash
    on Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugEngineeringHourlyReviewing

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions