From e00f37c7b1e73dd3451fd0e6d43da633f6ad0d1a Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Wed, 18 Jun 2025 10:58:19 +0700 Subject: [PATCH] After deleting expense and returning to Chats messages display fallback avatar --- src/components/Search/index.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/Search/index.tsx b/src/components/Search/index.tsx index c20b8f0eebe0..038702f7195f 100644 --- a/src/components/Search/index.tsx +++ b/src/components/Search/index.tsx @@ -177,9 +177,12 @@ function Search({queryJSON, currentSearchResults, lastNonEmptySearchResults, onS const shouldGroupByReports = groupBy === CONST.SEARCH.GROUP_BY.REPORTS; useEffect(() => { + if (!isFocused) { + return; + } clearSelectedTransactions(hash); setCurrentSearchHash(hash); - }, [hash, clearSelectedTransactions, setCurrentSearchHash]); + }, [hash, clearSelectedTransactions, setCurrentSearchHash, isFocused]); const searchResults = currentSearchResults?.data ? currentSearchResults : lastNonEmptySearchResults; const isSearchResultsEmpty = !searchResults?.data || isSearchResultsEmptyUtil(searchResults); @@ -217,12 +220,11 @@ function Search({queryJSON, currentSearchResults, lastNonEmptySearchResults, onS }, [isSmallScreenWidth, selectedTransactions, selectionMode?.isEnabled]); useEffect(() => { - if (isOffline) { + if (isOffline || !isFocused) { return; } - handleSearch({queryJSON, offset}); - }, [handleSearch, isOffline, offset, queryJSON]); + }, [handleSearch, isOffline, offset, queryJSON, isFocused]); const {newSearchResultKey, handleSelectionListScroll} = useSearchHighlightAndScroll({ searchResults,