Skip to content

Commit abad6bc

Browse files
committed
fix report creation bug
1 parent fad9174 commit abad6bc

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/hooks/useSearchHighlightAndScroll.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {useCallback, useEffect, useMemo, useRef, useState} from 'react';
33
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
44
import type {SearchQueryJSON} from '@components/Search/types';
55
import type {SearchListItem, SelectionListHandle, TransactionGroupListItemType, TransactionListItemType} from '@components/SelectionList/types';
6+
import useNetwork from '@hooks/useNetwork';
67
import {search} from '@libs/actions/Search';
78
import {isReportActionEntry} from '@libs/SearchUIUtils';
89
import 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

Comments
 (0)