Problem
useRestoreWorkspacesTabOnNavigate subscribes to the entire navigation state via useOnyx(ONYXKEYS.NAVIGATION_STATE), causing WorkspacesTabButton to re-render on every navigation action — regardless of whether the active workspace actually changed.
Since WorkspacesTabButton lives in the global tab bar, this affects all navigation actions across the app and is especially costly for accounts with large numbers of policies (e.g. 5k+ policies).
Impact
Measured on a large account with 5k policies:
- Web: no visible improvement
- Mobile (
ManualOpenReport of money request): 882ms → 713ms (19% faster)
This regression affects all navigation actions in the app, not just opening reports.
Root Cause
The useOnyx(ONYXKEYS.NAVIGATION_STATE) subscription in useRestoreWorkspacesTabOnNavigate triggers a re-render of WorkspacesTabButton on every navigation event, even when the workspace-related slice of state hasn't changed. A targeted selector should be used so re-renders only fire when the relevant part of the state actually changes.
Expected Behavior
WorkspacesTabButton should only re-render when the active workspace changes, not on every navigation action.
Related
Issue Owner
Current Issue Owner: @mallenexpensify
Problem
useRestoreWorkspacesTabOnNavigatesubscribes to the entire navigation state viauseOnyx(ONYXKEYS.NAVIGATION_STATE), causingWorkspacesTabButtonto re-render on every navigation action — regardless of whether the active workspace actually changed.Since
WorkspacesTabButtonlives in the global tab bar, this affects all navigation actions across the app and is especially costly for accounts with large numbers of policies (e.g. 5k+ policies).Impact
Measured on a large account with 5k policies:
ManualOpenReportof money request): 882ms → 713ms (19% faster)This regression affects all navigation actions in the app, not just opening reports.
Root Cause
The
useOnyx(ONYXKEYS.NAVIGATION_STATE)subscription inuseRestoreWorkspacesTabOnNavigatetriggers a re-render ofWorkspacesTabButtonon every navigation event, even when the workspace-related slice of state hasn't changed. A targeted selector should be used so re-renders only fire when the relevant part of the state actually changes.Expected Behavior
WorkspacesTabButtonshould only re-render when the active workspace changes, not on every navigation action.Related
Issue Owner
Current Issue Owner: @mallenexpensify