Skip to content

Commit c5909bf

Browse files
authored
Merge pull request Expensify#89088 from software-mansion-labs/@adamgrzybowski/fix-search-snapshot-refresh-from-rhp
Fix issue: Spend - New report does not appear in the background after moving expense to new report
2 parents ddef0ba + 4ce9664 commit c5909bf

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/hooks/useSearchHighlightAndScroll.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {SearchQueryJSON} from '@components/Search/types';
77
import type {SelectionListHandle} from '@components/SelectionList/types';
88
import {search} from '@libs/actions/Search';
99
import {mergeTransactionIdsHighlightOnSearchRoute} from '@libs/actions/Transaction';
10+
import isSearchTopmostFullScreenRoute from '@libs/Navigation/helpers/isSearchTopmostFullScreenRoute';
1011
import {isReportActionEntry} from '@libs/SearchUIUtils';
1112
import type {SearchKey} from '@libs/SearchUIUtils';
1213
import CONST from '@src/CONST';
@@ -100,8 +101,12 @@ function useSearchHighlightAndScroll({
100101

101102
// Check if there is a change in the transactions or report actions list
102103
if ((!isChat && hasTransactionsIDsChange) || hasReportActionsIDsChange || hasPendingSearchRef.current) {
103-
// If we're not focused or offline, don't trigger search
104-
if (!isFocused || isOffline) {
104+
// Skip if offline, or if the user has navigated to a different fullscreen page entirely.
105+
// An RHP layered on top of Search makes `isFocused` false but keeps Search as the topmost
106+
// fullscreen route, so we still want to refetch — otherwise the snapshot can't reflect
107+
// entries the user creates from the RHP until they close it.
108+
const isSearchStillActive = isFocused || isSearchTopmostFullScreenRoute();
109+
if (!isSearchStillActive || isOffline) {
105110
hasPendingSearchRef.current = true;
106111
return;
107112
}

0 commit comments

Comments
 (0)