Skip to content

[Due for payment 2026-06-01] perf: decouple toggleTransaction from filteredData #91288

@mountiny

Description

@mountiny

Problem

toggleTransaction in Search depended on filteredData because setSelectedTransactions took the visible rows as a second argument to derive selectedReports for bulk actions (export, approve, pay, etc.). filteredData is a large, reference-unstable array that changes on every search refresh, snapshot bump, filter change, or pagination. That kept toggleTransaction in the dependency array and forced the callback to be recreated constantly, churning memoized row items and footer controls.

Solution

Split report derivation out of setSelectedTransactions: moved the logic into deriveSelectedReports and a new setSelectedReports action, and added useSyncSelectedReports(filteredData) in the Search component to keep selectedReports in sync via a dedicated effect. toggleTransaction and other selection paths now call setSelectedTransactions without passing filteredData, so the callback no longer depends on the unstable search list reference while bulk actions still receive correct report metadata.

PR

#91188

Issue OwnerCurrent Issue Owner: @mallenexpensify

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions