diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 3ea88a1beeda..a90652a369fe 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -1,4 +1,4 @@ -import {useFocusEffect, useIsFocused, useNavigation} from '@react-navigation/native'; +import {findFocusedRoute, useFocusEffect, useIsFocused, useNavigation} from '@react-navigation/native'; import type {ContentStyle} from '@shopify/flash-list'; import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; import type {NativeScrollEvent, NativeSyntheticEvent, ViewToken} from 'react-native'; @@ -41,12 +41,14 @@ import { shouldShowYear as shouldShowYearUtil, } from '@libs/SearchUIUtils'; import {isOnHold, isTransactionPendingDelete} from '@libs/TransactionUtils'; -import Navigation from '@navigation/Navigation'; +import Navigation, {navigationRef} from '@navigation/Navigation'; import type {SearchFullscreenNavigatorParamList} from '@navigation/types'; import EmptySearchView from '@pages/Search/EmptySearchView'; import CONST from '@src/CONST'; +import NAVIGATORS from '@src/NAVIGATORS'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; +import SCREENS from '@src/SCREENS'; import type {ReportAction} from '@src/types/onyx'; import type SearchResults from '@src/types/onyx/SearchResults'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; @@ -235,7 +237,10 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS }, [isSmallScreenWidth, selectedTransactions, isMobileSelectionModeEnabled]); useEffect(() => { - if (!isFocused || isOffline) { + const focusedRoute = findFocusedRoute(navigationRef.getRootState()); + const isMigratedModalDisplayed = focusedRoute?.name === NAVIGATORS.MIGRATED_USER_MODAL_NAVIGATOR || focusedRoute?.name === SCREENS.MIGRATED_USER_WELCOME_MODAL.ROOT; + + if ((!isFocused && !isMigratedModalDisplayed) || isOffline) { return; }