@@ -16,7 +16,7 @@ import SearchTypeMenu from '@pages/Search/SearchTypeMenu';
1616import CONST from '@src/CONST' ;
1717import ONYXKEYS from '@src/ONYXKEYS' ;
1818import SCREENS from '@src/SCREENS' ;
19- import type { SearchResultsInfo } from '@src/types/onyx/SearchResults ' ;
19+ import type { SearchResults } from '@src/types/onyx' ;
2020import NavigationTabBar from './NavigationTabBar' ;
2121import NAVIGATION_TABS from './NavigationTabBar/NAVIGATION_TABS' ;
2222import TopBar from './TopBar' ;
@@ -43,24 +43,21 @@ function SearchSidebar({state}: SearchSidebarProps) {
4343 } , [ params ?. q ] ) ;
4444
4545 const currentSearchResultsKey = queryJSON ?. hash ?? CONST . DEFAULT_NUMBER_ID ;
46- const [ currentSearchResults ] = useOnyx ( `${ ONYXKEYS . COLLECTION . SNAPSHOT } ${ currentSearchResultsKey } ` , { canBeMissing : true , selector : ( snapshot ) => snapshot ?. search } ) ;
47- const [ lastNonEmptySearchResults , setLastNonEmptySearchResults ] = useState < SearchResultsInfo | undefined > ( undefined ) ;
46+ const [ currentSearchResults ] = useOnyx ( `${ ONYXKEYS . COLLECTION . SNAPSHOT } ${ currentSearchResultsKey } ` , { canBeMissing : true } ) ;
47+ const [ lastNonEmptySearchResults , setLastNonEmptySearchResults ] = useState < SearchResults | undefined > ( undefined ) ;
4848
4949 useEffect ( ( ) => {
50- if ( ! currentSearchResults ?. type ) {
50+ if ( ! currentSearchResults ?. search ?. type ) {
5151 return ;
5252 }
5353
54- setLastSearchType ( currentSearchResults . type ) ;
55- if ( currentSearchResults . hasResults ?? currentSearchResults . hasMoreResults ) {
54+ setLastSearchType ( currentSearchResults . search . type ) ;
55+ if ( currentSearchResults . data ) {
5656 setLastNonEmptySearchResults ( currentSearchResults ) ;
5757 }
5858 } , [ lastSearchType , queryJSON , setLastSearchType , currentSearchResults ] ) ;
5959
60- const searchResultsToUse = ( currentSearchResults ?. hasResults ?? currentSearchResults ?. hasMoreResults ) ? currentSearchResults : lastNonEmptySearchResults ;
61-
62- const isDataLoaded = isSearchDataLoaded ( searchResultsToUse , queryJSON ) ;
63-
60+ const isDataLoaded = isSearchDataLoaded ( currentSearchResults ?. data ? currentSearchResults : lastNonEmptySearchResults , queryJSON ) ;
6461 const shouldShowLoadingState = route ?. name === SCREENS . SEARCH . MONEY_REQUEST_REPORT ? false : ! isOffline && ! isDataLoaded ;
6562
6663 if ( shouldUseNarrowLayout ) {
0 commit comments