@@ -3,6 +3,7 @@ import {useCallback, useEffect, useMemo, useRef, useState} from 'react';
33import type { OnyxCollection , OnyxEntry } from 'react-native-onyx' ;
44import type { SearchQueryJSON } from '@components/Search/types' ;
55import type { SearchListItem , SelectionListHandle , TransactionGroupListItemType , TransactionListItemType } from '@components/SelectionList/types' ;
6+ import useNetwork from '@hooks/useNetwork' ;
67import { search } from '@libs/actions/Search' ;
78import { isReportActionEntry } from '@libs/SearchUIUtils' ;
89import type { SearchKey } from '@libs/SearchUIUtils' ;
@@ -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