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-04-07][Performance] Optimize ExpenseReportListItemRow #86487
After this PR (deployed in v9.3.38-4), we started subscribing to the whole ONYXKEYS.COLLECTION.POLICY_TAGS key and then passes the result into helper functions, which causes the whole search list to slow down. Additionally, the values change reference ~3 times, which triggers re-renders of the whole page.
changed the title [-][Performance] Optimize ExpenseReportListItemRow[/-][+][Due for payment 2026-04-07][Performance] Optimize ExpenseReportListItemRow[/+]on Apr 14, 2026
Root Cause: PR Expensify/App#83545 (v9.3.38-4) added useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS) subscriptions without a selector across multiple components. Without a selector, useOnyx uses shallow equality comparison. The POLICY_TAGS collection's internal tags property produces a new object reference on each Onyx hydration cycle (~3 times), even when the data is identical. Shallow comparison sees a different reference and returns a "new" value, which invalidates every downstream useMemo — including the expensive getValidOptions/getSearchOptions computations in useSearchSelector.base.ts — causing full search list re-renders.
Fix (merged): PR Expensify/App#86327 introduced a passthrough identity selector (passthroughPolicyTagListSelector) applied to every useOnyx(POLICY_TAGS) call. The selector itself is a no-op (returns input unchanged), but supplying any selector switches useOnyx to its memoized comparison path, which correctly returns a stable reference when data hasn't changed. This eliminates the spurious re-renders.
Data flow of the bug
useOnyx subscribes to POLICY_TAGS collection without selector
Onyx hydration cycle produces new object reference for tags property ~3 times
Shallow equality check fails → useOnyx returns new reference
allPolicyTags dependency changes in useMemo → recomputes expensive getValidOptions/getSearchOptions
Entire search list re-renders
Files changed in fix:src/selectors/PolicyTagList.ts (new selector), src/hooks/useSearchSelector.base.ts, src/components/MoneyReportHeader.tsx, src/components/Search/SearchAutocompleteInput.tsx, src/components/Search/SearchFiltersChatsSelector.tsx, src/hooks/useAdvancedSearchFilters.ts, src/hooks/useAutocompleteSuggestions.ts, src/hooks/useDeleteTransactions.ts, src/pages/NewChatPage.tsx, src/pages/Search/SearchAdvancedFiltersPage/SearchFiltersTagPage.tsx
Note: This passthrough selector is explicitly documented as a workaround. #86181 tracks a proper fix inside Onyx's equality logic so these passthrough selectors can be removed.
Status: Fix merged via #86327 on 2026-03-27. Issue is in Awaiting Payment.
Next Steps: Reply with @MelvinBot <your feedback> to refine this analysis.
Activity
parasharrajat commentedon Mar 26, 2026
Happy to be C+ here as I reviewed original PR and know what to check.
luacmartins commentedon Mar 26, 2026
The team is assembled!
jmusial commentedon Mar 27, 2026
Opened the PR here
parasharrajat commentedon Apr 14, 2026
This should be ready for summary @luacmartins
[-][Performance] Optimize ExpenseReportListItemRow[/-][+][Due for payment 2026-04-07][Performance] Optimize ExpenseReportListItemRow[/+]melvin-bot commentedon Apr 14, 2026
Triggered auto assignment to @mallenexpensify (
Awaiting Payment)MelvinBot commentedon Apr 14, 2026
Issue Analysis
Root Cause: PR Expensify/App#83545 (v9.3.38-4) added
useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS)subscriptions without a selector across multiple components. Without a selector,useOnyxuses shallow equality comparison. ThePOLICY_TAGScollection's internaltagsproperty produces a new object reference on each Onyx hydration cycle (~3 times), even when the data is identical. Shallow comparison sees a different reference and returns a "new" value, which invalidates every downstreamuseMemo— including the expensivegetValidOptions/getSearchOptionscomputations inuseSearchSelector.base.ts— causing full search list re-renders.Fix (merged): PR Expensify/App#86327 introduced a passthrough identity selector (
passthroughPolicyTagListSelector) applied to everyuseOnyx(POLICY_TAGS)call. The selector itself is a no-op (returns input unchanged), but supplying any selector switchesuseOnyxto its memoized comparison path, which correctly returns a stable reference when data hasn't changed. This eliminates the spurious re-renders.Data flow of the bug
useOnyxsubscribes toPOLICY_TAGScollection without selectortagsproperty ~3 timesuseOnyxreturns new referenceallPolicyTagsdependency changes inuseMemo→ recomputes expensivegetValidOptions/getSearchOptionsFiles changed in fix:
src/selectors/PolicyTagList.ts(new selector),src/hooks/useSearchSelector.base.ts,src/components/MoneyReportHeader.tsx,src/components/Search/SearchAutocompleteInput.tsx,src/components/Search/SearchFiltersChatsSelector.tsx,src/hooks/useAdvancedSearchFilters.ts,src/hooks/useAutocompleteSuggestions.ts,src/hooks/useDeleteTransactions.ts,src/pages/NewChatPage.tsx,src/pages/Search/SearchAdvancedFiltersPage/SearchFiltersTagPage.tsxNote: This passthrough selector is explicitly documented as a workaround. #86181 tracks a proper fix inside Onyx's equality logic so these passthrough selectors can be removed.
Status: Fix merged via #86327 on 2026-03-27. Issue is in
Awaiting Payment.Next Steps: Reply with
@MelvinBot <your feedback>to refine this analysis.mallenexpensify commentedon Apr 14, 2026
Payment Summary
Contributor+: @parasharrajat due $250 via NewDot
parasharrajat commentedon Apr 20, 2026
Payment requested as per #86487 (comment)
garrettmknight commentedon Apr 23, 2026
$250 approved for @parasharrajat