@@ -56,7 +56,6 @@ import {
5656 isTransactionGroupListItemType ,
5757 isTransactionListItemType ,
5858 isTransactionReportGroupListItemType ,
59- isTransactionSearchType ,
6059 shouldShowEmptyState ,
6160 shouldShowYear as shouldShowYearUtil ,
6261} from '@libs/SearchUIUtils' ;
@@ -84,6 +83,7 @@ import {useSearchActionsContext, useSearchStateContext} from './SearchContext';
8483import SearchList from './SearchList' ;
8584import type { ReportActionListItemType , SearchListItem , TransactionGroupListItemType , TransactionListItemType , TransactionReportGroupListItemType } from './SearchList/ListItem/types' ;
8685import { SearchScopeProvider } from './SearchScopeProvider' ;
86+ import SearchStaticList from './SearchStaticList' ;
8787import SearchTableHeader from './SearchTableHeader' ;
8888import type { SearchColumnType , SearchParams , SearchQueryJSON , SelectedTransactionInfo , SelectedTransactions , SortOrder } from './types' ;
8989
@@ -1462,21 +1462,14 @@ function Search({
14621462 searchResults ?. data ,
14631463 ] ) ;
14641464
1465- const onLayoutBase = useCallback ( ( ) => {
1465+ const onLayout = useCallback ( ( ) => {
14661466 hasHadFirstLayout . current = true ;
14671467 onDestinationVisible ?.( isSearchResultsEmptyRef . current , 'layout' ) ;
14681468 endSpanWithAttributes ( CONST . TELEMETRY . SPAN_NAVIGATE_TO_REPORTS , { [ CONST . TELEMETRY . ATTRIBUTE_IS_WARM ] : true } ) ;
1469- flushDeferredWrite ( CONST . DEFERRED_LAYOUT_WRITE_KEYS . SEARCH ) ;
1470- } , [ onDestinationVisible ] ) ;
1471-
1472- // Deferred layout only needs the base work (no scroll handling, no content-ready signal).
1473- const onDeferredLayout = onLayoutBase ;
1474-
1475- const onLayout = useCallback ( ( ) => {
1476- onLayoutBase ( ) ;
14771469 handleSelectionListScroll ( stableSortedData , searchListRef . current ) ;
1470+ flushDeferredWrite ( CONST . DEFERRED_LAYOUT_WRITE_KEYS . SEARCH ) ;
14781471 onContentReady ?.( ) ;
1479- } , [ onLayoutBase , handleSelectionListScroll , stableSortedData , onContentReady ] ) ;
1472+ } , [ handleSelectionListScroll , stableSortedData , onContentReady , onDestinationVisible ] ) ;
14801473
14811474 // Must be a ref, not state: cancelNavigationSpans is called during render
14821475 // (inside conditional returns), so using setState would trigger infinite re-renders.
@@ -1572,14 +1565,25 @@ function Search({
15721565 ) ;
15731566
15741567 // When heavy work is deferred (e.g. during the RHP dismiss animation after
1575- // submitting an expense), skip the expensive render below. The ancestor
1576- // SearchPage (via SearchPageNarrow / SearchPageWide) renders a SearchStaticList
1577- // overlay that covers this component, so the user sees real-looking content.
1578- // The minimal View fires onLayout to flush the deferred API write and set
1579- // hasHadFirstLayout.
1580- if ( isDeferringHeavyWork && searchResults ?. data && isTransactionSearchType ( type ) ) {
1581- // Zero-sized View - onLayout still fires on RN, which is all we need here.
1582- return < View onLayout = { onDeferredLayout } /> ;
1568+ // submitting an expense), show a lightweight static list instead of the skeleton.
1569+ // This gives the user real-looking content during the animation while avoiding
1570+ // the expensive hooks and renders of the full Search component.
1571+ // Restricted to transaction-based search types (expense/invoice) because
1572+ // SearchStaticList only renders rows with a transactionID - non-transaction
1573+ // types (chat, task, report) would render empty/blank during the deferral.
1574+ const isTransactionSearchType = type === CONST . SEARCH . DATA_TYPES . EXPENSE || type === CONST . SEARCH . DATA_TYPES . INVOICE ;
1575+ if ( isDeferringHeavyWork && searchResults ?. data && isTransactionSearchType ) {
1576+ return (
1577+ < SearchStaticList
1578+ searchResults = { searchResults }
1579+ queryJSON = { queryJSON }
1580+ shouldUseNarrowLayout = { shouldUseNarrowLayout }
1581+ canSelectMultiple = { canSelectMultiple }
1582+ columns = { currentColumns }
1583+ contentContainerStyle = { shouldUseNarrowLayout ? styles . searchListContentContainerStyles ( ! ! hasFilterBars ) : undefined }
1584+ onLayout = { onLayout }
1585+ />
1586+ ) ;
15831587 }
15841588
15851589 // This is a performance optimization for the submit-expense->search path only.
0 commit comments