Skip to content

Commit 7b5ab5d

Browse files
leshniakclaude
andcommitted
Fix navigation arrows disappearing during report browsing
Background search calls (useSearchHighlightAndScroll, useSearchPageSetup) overwrote REPORT_NAVIGATION_LAST_SEARCH_QUERY with a different search type, causing prev/next arrows to hide. Flip shouldUpdateLastSearchParams default to false in search() so background calls no longer overwrite the navigation context. Persist params explicitly when user selects an expense report row (onSelectRow) and when arrows prefetch more results (goToNextReport). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1d7d446 commit 7b5ab5d

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

src/components/MoneyRequestReportView/MoneyRequestReportNavigation.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ function MoneyRequestReportNavigation({reportID, shouldDisplayNarrowVersion}: Mo
8484
shouldCalculateTotals: false,
8585
searchKey: lastSearchQuery.searchKey,
8686
isLoading: isSearchLoading,
87+
shouldUpdateLastSearchParams: true,
8788
});
8889
}
8990

src/components/Search/index.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import useSearchHighlightAndScroll from '@hooks/useSearchHighlightAndScroll';
2323
import useSearchShouldCalculateTotals from '@hooks/useSearchShouldCalculateTotals';
2424
import useThemeStyles from '@hooks/useThemeStyles';
2525
import {turnOffMobileSelectionMode, turnOnMobileSelectionMode} from '@libs/actions/MobileSelectionMode';
26+
import {saveLastSearchParams} from '@libs/actions/ReportNavigation';
2627
import type {TransactionPreviewData} from '@libs/actions/Search';
2728
import {setOptimisticDataForTransactionThreadPreview} from '@libs/actions/Search';
2829
import {flushDeferredWrite, getOptimisticWatchKey, hasDeferredWrite} from '@libs/deferredLayoutWrite';
@@ -1136,6 +1137,16 @@ function Search({
11361137
unmarkReportIDAsMultiTransactionExpense(reportID);
11371138
}
11381139

1140+
// Persist the current search context so prev/next navigation arrows
1141+
// in the report RHP can reference the correct result set.
1142+
saveLastSearchParams({
1143+
queryJSON,
1144+
offset,
1145+
searchKey: currentSearchKey,
1146+
hasMoreResults: !!searchResults?.search?.hasMoreResults,
1147+
allowPostSearchRecount: true,
1148+
});
1149+
11391150
requestAnimationFrame(() => Navigation.navigate(ROUTES.SEARCH_MONEY_REQUEST_REPORT.getRoute({reportID, backTo})));
11401151
return;
11411152
}
@@ -1176,6 +1187,9 @@ function Search({
11761187
betas,
11771188
email,
11781189
accountID,
1190+
queryJSON,
1191+
offset,
1192+
searchResults?.search?.hasMoreResults,
11791193
],
11801194
);
11811195

src/libs/actions/Search.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ function search({
516516
prevReportsLength,
517517
isOffline = false,
518518
isLoading,
519-
shouldUpdateLastSearchParams = true,
519+
shouldUpdateLastSearchParams = false,
520520
skipWaitForWrites = false,
521521
}: {
522522
queryJSON: SearchQueryJSON;

0 commit comments

Comments
 (0)