From 965f569da67a91acaadf9a84d91e82de39c9c023 Mon Sep 17 00:00:00 2001 From: VickyStash Date: Thu, 24 Jul 2025 13:05:41 +0200 Subject: [PATCH 1/4] Call Search API call if user just finished the migration --- src/components/Search/index.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 3ea88a1beeda..ae56d95a1425 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -47,6 +47,7 @@ import EmptySearchView from '@pages/Search/EmptySearchView'; import CONST from '@src/CONST'; 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 +236,12 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS }, [isSmallScreenWidth, selectedTransactions, isMobileSelectionModeEnabled]); useEffect(() => { - if (!isFocused || isOffline) { + const activeRoute = Navigation.getActiveRoute(); + const screenParamMatch = activeRoute.match(/screen=([^&]+)/); + const screenParam = screenParamMatch ? decodeURIComponent(screenParamMatch[1]) : null; + const isMigratedModalDisplay = activeRoute.includes(ROUTES.MIGRATED_USER_WELCOME_MODAL.getRoute(true)) || screenParam === SCREENS.MIGRATED_USER_WELCOME_MODAL.ROOT; + + if (!(isFocused || isMigratedModalDisplay) || isOffline) { return; } From 8d6eb10fb4289c480e8ea8ec58de4e1342468257 Mon Sep 17 00:00:00 2001 From: VickyStash Date: Fri, 25 Jul 2025 09:11:49 +0200 Subject: [PATCH 2/4] Apply reviewer feedback --- src/components/Search/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index ae56d95a1425..ba859daecd4f 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -241,7 +241,7 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS const screenParam = screenParamMatch ? decodeURIComponent(screenParamMatch[1]) : null; const isMigratedModalDisplay = activeRoute.includes(ROUTES.MIGRATED_USER_WELCOME_MODAL.getRoute(true)) || screenParam === SCREENS.MIGRATED_USER_WELCOME_MODAL.ROOT; - if (!(isFocused || isMigratedModalDisplay) || isOffline) { + if ((!isFocused && !isMigratedModalDisplay) || isOffline) { return; } From 499252c31b2ac13e924c1cae848275928c88d3e7 Mon Sep 17 00:00:00 2001 From: VickyStash Date: Fri, 25 Jul 2025 14:27:09 +0200 Subject: [PATCH 3/4] Rename the variable --- src/components/Search/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index ba859daecd4f..8edfb6be93e2 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -239,9 +239,9 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS const activeRoute = Navigation.getActiveRoute(); const screenParamMatch = activeRoute.match(/screen=([^&]+)/); const screenParam = screenParamMatch ? decodeURIComponent(screenParamMatch[1]) : null; - const isMigratedModalDisplay = activeRoute.includes(ROUTES.MIGRATED_USER_WELCOME_MODAL.getRoute(true)) || screenParam === SCREENS.MIGRATED_USER_WELCOME_MODAL.ROOT; + const isMigratedModalDisplayed = activeRoute.includes(ROUTES.MIGRATED_USER_WELCOME_MODAL.getRoute(true)) || screenParam === SCREENS.MIGRATED_USER_WELCOME_MODAL.ROOT; - if ((!isFocused && !isMigratedModalDisplay) || isOffline) { + if ((!isFocused && !isMigratedModalDisplayed) || isOffline) { return; } From 6d396cce8a6119c8316b9903b13916aa8b15e525 Mon Sep 17 00:00:00 2001 From: VickyStash Date: Fri, 25 Jul 2025 15:36:57 +0200 Subject: [PATCH 4/4] Simplify the check --- src/components/Search/index.tsx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index 8edfb6be93e2..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,10 +41,11 @@ 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'; @@ -236,10 +237,8 @@ function Search({queryJSON, searchResults, onSearchListScroll, contentContainerS }, [isSmallScreenWidth, selectedTransactions, isMobileSelectionModeEnabled]); useEffect(() => { - const activeRoute = Navigation.getActiveRoute(); - const screenParamMatch = activeRoute.match(/screen=([^&]+)/); - const screenParam = screenParamMatch ? decodeURIComponent(screenParamMatch[1]) : null; - const isMigratedModalDisplayed = activeRoute.includes(ROUTES.MIGRATED_USER_WELCOME_MODAL.getRoute(true)) || screenParam === SCREENS.MIGRATED_USER_WELCOME_MODAL.ROOT; + 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;