Skip to content

[Due for payment 2026-04-07][Performance] Optimize ExpenseReportListItemRow #86487

Closed

Description

@luacmartins

Problem

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.

Solution

#86327

Issue OwnerCurrent Issue Owner: @mallenexpensify
Issue OwnerCurrent Issue Owner: @parasharrajat

Activity

  1. parasharrajat commented on Mar 26, 2026

    @parasharrajat
    Member

    Happy to be C+ here as I reviewed original PR and know what to check.

  2. luacmartins commented on Mar 26, 2026

    @luacmartins
    ContributorAuthor

    The team is assembled!

  3. jmusial commented on Mar 27, 2026

    @jmusial
    Contributor

    Opened the PR here

  4. parasharrajat commented on Apr 14, 2026

    @parasharrajat
    Member

    This should be ready for summary @luacmartins

  5. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Apr 14, 2026
  6. changed the title [-][Performance] Optimize ExpenseReportListItemRow[/-] [+][Due for payment 2026-04-07][Performance] Optimize ExpenseReportListItemRow[/+] on Apr 14, 2026
  7. added
    Awaiting PaymentAuto-added when associated PR is deployed to production
    and removed
    ReviewingHas a PR in review
    on Apr 14, 2026
  8. melvin-bot commented on Apr 14, 2026

    @melvin-bot

    Triggered auto assignment to @mallenexpensify (Awaiting Payment)

  9. MelvinBot commented on Apr 14, 2026

    @MelvinBot
    Contributor

    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, 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
    1. useOnyx subscribes to POLICY_TAGS collection without selector
    2. Onyx hydration cycle produces new object reference for tags property ~3 times
    3. Shallow equality check fails → useOnyx returns new reference
    4. allPolicyTags dependency changes in useMemo → recomputes expensive getValidOptions/getSearchOptions
    5. 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.

  10. mallenexpensify commented on Apr 14, 2026

    @mallenexpensify
    Contributor

    Payment Summary

    Contributor+: @parasharrajat due $250 via NewDot

  11. parasharrajat commented on Apr 20, 2026

    @parasharrajat
    Member

    Payment requested as per #86487 (comment)

  12. garrettmknight commented on Apr 23, 2026

    @garrettmknight
    Contributor

    $250 approved for @parasharrajat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions