Problem
In Search, updateSelectAllMatchingItemsState recalculated totalSelectableItemsCount on every invocation by scanning filteredData (including grouped expense reports and pending-delete filtering). The callback also depended on filteredData, validGroupBy, and search type, so it was recreated frequently and repeated expensive counting work during row selection.
Solution
Hoisted totalSelectableItemsCount into a useMemo keyed on areItemsGrouped and filteredData, and updated updateSelectAllMatchingItemsState to read the memoized count instead of recomputing it. Narrowed the callback dependency list to totalSelectableItemsCount and the select-all-matching flags, and reused the shared areItemsGrouped flag in toggleAllTransactions to avoid duplicate logic.
PR
#91186
Issue Owner
Current Issue Owner: @mallenexpensify
Problem
In Search,
updateSelectAllMatchingItemsStaterecalculatedtotalSelectableItemsCounton every invocation by scanningfilteredData(including grouped expense reports and pending-delete filtering). The callback also depended onfilteredData,validGroupBy, and search type, so it was recreated frequently and repeated expensive counting work during row selection.Solution
Hoisted
totalSelectableItemsCountinto auseMemokeyed onareItemsGroupedandfilteredData, and updatedupdateSelectAllMatchingItemsStateto read the memoized count instead of recomputing it. Narrowed the callback dependency list tototalSelectableItemsCountand the select-all-matching flags, and reused the sharedareItemsGroupedflag intoggleAllTransactionsto avoid duplicate logic.PR
#91186
Issue Owner
Current Issue Owner: @mallenexpensify