Skip to content

Commit 8dce6b3

Browse files
authored
Merge pull request Expensify#67966 from Expensify/cmartins-fixReportCreation
Fix report creation bug
2 parents 1cc7439 + 071a49a commit 8dce6b3

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
@@ -9,6 +9,7 @@ import type {SearchKey} from '@libs/SearchUIUtils';
99
import CONST from '@src/CONST';
1010
import ONYXKEYS from '@src/ONYXKEYS';
1111
import type {ReportActions, SearchResults, Transaction} from '@src/types/onyx';
12+
import useNetwork from './useNetwork';
1213
import usePrevious from './usePrevious';
1314

1415
type 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

Comments
 (0)