You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-12-08] [$175] perf: Keep SearchQueryContext stable when an unrelated policy changes #107758
The Spend page re-renders on every policy update, even when nothing it shows changed. SearchQueryProvider subscribes to the whole policy_ collection to compute one flag, shouldShowExpensifyCard, so any policy write rebuilds the SearchQueryContext value and re-renders every consumer. SearchTypeMenuNarrow also builds its tabs from menu sections that are recomputed on every policy, card or report write, so every tab re-renders.
Solution
SearchQueryProvider now selects only the shouldShowExpensifyCard boolean, so unrelated policy writes no longer change the context value. SearchTypeMenuNarrow keeps the previous tabs and queries while they are deeply equal, and builds the saved search overflow menu only for the search being edited. A new useStableReference(value, isEqual) hook backs this, and useStableObjectReference and useStableArrayReference now wrap it.
changed the title [-]perf: Keep SearchQueryContext stable when an unrelated policy changes[/-][+][$175] perf: Keep SearchQueryContext stable when an unrelated policy changes[/+]on Nov 23, 2026
Confidence: Medium — source evidence supports the reported mechanism; render counts and timings were not independently reproduced.
What is the root cause of that problem?
Two independent paths propagate reference changes even when the displayed search data is unchanged:
Search context: The provider subscribes to the entire policy collection but uses it only to derive shouldShowExpensifyCard. Unrelated policy writes invalidate downstream derivations and the context consumed by search components.
Narrow search menu: Rebuilt tab/query containers and overflow-menu-dependent callbacks prevent reuse of the tab subtree.
Select the visibility boolean at the subscription boundary.
Retain equivalent tabs and navigation queries, so unchanged menus remain stable without retaining outdated queries.
Construct overflow actions only for the selected saved search.
Continue with that PR rather than opening a duplicate. Before acceptance, verify unrelated writes preserve context/tab identity while meaningful changes still update correctly.
Validation and remaining gaps
The provider regression tests cover unchanged context identity after a workspace rename and updated reconciliation queries after enabling cards.
Remaining useful coverage:
Disabling cards or removing the last qualifying workspace.
Updating a saved search’s query without changing its visible title.
Unrelated writes versus genuine tab changes in the narrow menu, including overflow actions.
An alternative explanation—remaining policy subscriptions—does explain residual renders, but does not invalidate the targeted context stabilization. Backend logs are unnecessary for this client-side mechanism. Tests and browser profiling were not independently run.
What alternative solutions did you explore? (Optional)
Stabilizing only the tabs would leave query/callback churn unresolved. Suppressing all policy updates would incorrectly hide legitimate visibility changes.
Next Steps for Contributor+ team: To accept: Review the existing PR; no additional implementation PR is needed. To refine:@MelvinBot <your feedback> To reject: Explain why you are rejecting Melvin’s proposal.
changed the title [-][$175] perf: Keep SearchQueryContext stable when an unrelated policy changes[/-][+][Due for payment 2026-12-08] [$175] perf: Keep SearchQueryContext stable when an unrelated policy changes[/+]on Dec 1, 2026
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.5.55-6 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2026-12-08. 🎊
The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the Contributor+ Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]
This is a performance improvement with no UI changes, so no new regression tests are needed. It's also not directly coming from an Issue or any specific PR.
Activity
expensify-chore-bot commentedon Nov 23, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @jayeshmangwani (
External)[-]perf: Keep SearchQueryContext stable when an unrelated policy changes[/-][+][$175] perf: Keep SearchQueryContext stable when an unrelated policy changes[/+]expensify-chore-bot commentedon Nov 23, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022124933880238680200
MelvinBot commentedon Nov 23, 2026
Proposal
Confidence: Medium — source evidence supports the reported mechanism; render counts and timings were not independently reproduced.
What is the root cause of that problem?
Two independent paths propagate reference changes even when the displayed search data is unchanged:
shouldShowExpensifyCard. Unrelated policy writes invalidate downstream derivations and the context consumed by search components.Code evidence and scope
What changes do you think we should make in order to solve the problem?
The existing Keep SearchQueryContext stable PR addresses both paths appropriately:
Continue with that PR rather than opening a duplicate. Before acceptance, verify unrelated writes preserve context/tab identity while meaningful changes still update correctly.
Validation and remaining gaps
The provider regression tests cover unchanged context identity after a workspace rename and updated reconciliation queries after enabling cards.
Remaining useful coverage:
An alternative explanation—remaining policy subscriptions—does explain residual renders, but does not invalidate the targeted context stabilization. Backend logs are unnecessary for this client-side mechanism. Tests and browser profiling were not independently run.
What alternative solutions did you explore? (Optional)
Stabilizing only the tabs would leave query/callback churn unresolved. Suppressing all policy updates would incorrectly hide legitimate visibility changes.
Related work: Keep to-do search data stable on unrelated writes and Keep cached Onyx arrays when re-sent data is unchanged. These are related performance efforts, not confirmed duplicates.
Next Steps for Contributor+ team:
To accept: Review the existing PR; no additional implementation PR is needed.
To refine:
@MelvinBot <your feedback>To reject: Explain why you are rejecting Melvin’s proposal.
view run
[-][$175] perf: Keep SearchQueryContext stable when an unrelated policy changes[/-][+][Due for payment 2026-12-08] [$175] perf: Keep SearchQueryContext stable when an unrelated policy changes[/+]melvin-bot commentedon Dec 1, 2026
@jayeshmangwani
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.5.55-6 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2026-12-08. 🎊
The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the Contributor+ Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]. If no checklist is needed for this issue, you can click: [no checklist button]
jayeshmangwani commentedon Dec 2, 2026
No Checklist Needed
This is a performance improvement with no UI changes, so no new regression tests are needed. It's also not directly coming from an Issue or any specific PR.