@@ -9,6 +9,7 @@ import type {SearchKey} from '@libs/SearchUIUtils';
99import CONST from '@src/CONST' ;
1010import ONYXKEYS from '@src/ONYXKEYS' ;
1111import type { ReportActions , SearchResults , Transaction } from '@src/types/onyx' ;
12+ import useNetwork from './useNetwork' ;
1213import usePrevious from './usePrevious' ;
1314
1415type UseSearchHighlightAndScroll = {
@@ -38,6 +39,7 @@ function useSearchHighlightAndScroll({
3839 shouldCalculateTotals,
3940} : UseSearchHighlightAndScroll ) {
4041 const isFocused = useIsFocused ( ) ;
42+ const { isOffline} = useNetwork ( ) ;
4143 // Ref to track if the search was triggered by this hook
4244 const triggeredByHookRef = useRef ( false ) ;
4345 const searchTriggeredRef = useRef ( false ) ;
@@ -81,8 +83,8 @@ function useSearchHighlightAndScroll({
8183
8284 // Check if there is a change in the transactions or report actions list
8385 if ( ( ! isChat && hasTransactionsIDsChange ) || hasReportActionsIDsChange || hasPendingSearchRef . current ) {
84- // If we're not focused, don't trigger search
85- if ( ! isFocused ) {
86+ // If we're not focused or offline , don't trigger search
87+ if ( ! isFocused || isOffline ) {
8688 hasPendingSearchRef . current = true ;
8789 return ;
8890 }
@@ -128,6 +130,7 @@ function useSearchHighlightAndScroll({
128130 isChat ,
129131 searchResults ?. data ,
130132 existingSearchResultIDs ,
133+ isOffline ,
131134 ] ) ;
132135
133136 // Initialize the set with existing IDs only once
0 commit comments