Skip to content
10 changes: 9 additions & 1 deletion src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@
const shouldShowLoadingMoreItems = !shouldShowLoadingState && searchResults?.search?.isLoading && searchResults?.search?.offset > 0;
const prevIsSearchResultEmpty = usePrevious(isSearchResultsEmpty);

const [allReportNameValuePairs] = useOnyx(ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, {canBeMissing: true});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussing here how safe this from performance perspective for large accounts https://expensify.slack.com/archives/C05LX9D6E07/p1761135629353109


const [data, dataLength] = useMemo(() => {
if (searchResults === undefined || !isDataLoaded) {
return [[], 0];
Expand All @@ -389,9 +391,15 @@
return [[], 0];
}

const data1 = getSections(type, searchResults.data, accountID, formatPhoneNumber, groupBy, exportReportActions, searchKey, archivedReportsIdSet, queryJSON);
// Merging live REPORT_NAME_VALUE_PAIRS into search data to get latest archived status for both online and offline
const mergedSearchData = {
...searchResults.data,
...allReportNameValuePairs,
};

const data1 = getSections(type, mergedSearchData, accountID, formatPhoneNumber, groupBy, exportReportActions, searchKey, archivedReportsIdSet, queryJSON);
return [data1, data1.length];
}, [searchKey, exportReportActions, groupBy, isDataLoaded, searchResults, type, archivedReportsIdSet, formatPhoneNumber, accountID, queryJSON]);

Check warning on line 402 in src/components/Search/index.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useMemo has a missing dependency: 'allReportNameValuePairs'. Either include it or remove the dependency array

useEffect(() => {
/** We only want to display the skeleton for the status filters the first time we load them for a specific data type */
Expand Down
Loading