@@ -17,6 +17,7 @@ import type {SearchParams, SearchQueryJSON} from '@components/Search/types';
1717import useHandleBackButton from '@hooks/useHandleBackButton' ;
1818import useLocalize from '@hooks/useLocalize' ;
1919import useNetwork from '@hooks/useNetwork' ;
20+ import useOnyx from '@hooks/useOnyx' ;
2021import useResponsiveLayout from '@hooks/useResponsiveLayout' ;
2122import useScrollEventEmitter from '@hooks/useScrollEventEmitter' ;
2223import useStyleUtils from '@hooks/useStyleUtils' ;
@@ -29,6 +30,8 @@ import {isSearchDataLoaded} from '@libs/SearchUIUtils';
2930import variables from '@styles/variables' ;
3031import { searchInServer } from '@userActions/Report' ;
3132import { search } from '@userActions/Search' ;
33+ import CONST from '@src/CONST' ;
34+ import ONYXKEYS from '@src/ONYXKEYS' ;
3235import ROUTES from '@src/ROUTES' ;
3336import type { SearchResults } from '@src/types/onyx' ;
3437
@@ -52,7 +55,8 @@ function SearchPageNarrow({queryJSON, headerButtonsOptions, searchResults, isMob
5255 const { clearSelectedTransactions} = useSearchContext ( ) ;
5356 const [ searchRouterListVisible , setSearchRouterListVisible ] = useState ( false ) ;
5457 const { isOffline} = useNetwork ( ) ;
55-
58+ const currentSearchResultsKey = queryJSON ?. hash ?? CONST . DEFAULT_NUMBER_ID ;
59+ const [ currentSearchResults ] = useOnyx ( `${ ONYXKEYS . COLLECTION . SNAPSHOT } ${ currentSearchResultsKey } ` , { canBeMissing : true } ) ;
5660 // Controls the visibility of the educational tooltip based on user scrolling.
5761 // Hides the tooltip when the user is scrolling and displays it once scrolling stops.
5862 const triggerScrollEvent = useScrollEventEmitter ( ) ;
@@ -136,7 +140,7 @@ function SearchPageNarrow({queryJSON, headerButtonsOptions, searchResults, isMob
136140 }
137141
138142 const isDataLoaded = isSearchDataLoaded ( searchResults , queryJSON ) ;
139- const shouldShowLoadingState = ! isOffline && ! isDataLoaded ;
143+ const shouldShowLoadingState = ! isOffline && ( ! isDataLoaded || ! ! currentSearchResults ?. search ?. isLoading ) ;
140144
141145 return (
142146 < ScreenWrapper
0 commit comments