diff --git a/src/pages/Search/SearchMoneyRequestReportPage.tsx b/src/pages/Search/SearchMoneyRequestReportPage.tsx index e2f585a48f867..5a916ac90bf94 100644 --- a/src/pages/Search/SearchMoneyRequestReportPage.tsx +++ b/src/pages/Search/SearchMoneyRequestReportPage.tsx @@ -261,7 +261,13 @@ function SearchMoneyRequestReportPage({route}: SearchMoneyRequestPageProps) { // Create transaction thread for legacy transactions that don't have one yet. // Wait for all data to load to avoid duplicates or stale data when navigating between reports. useEffect(() => { - if (hasCreatedLegacyThreadRef.current || transactionThreadReportID || (Object.keys(allReportTransactions).length !== 1 && !snapshotTransaction)) { + if ( + hasCreatedLegacyThreadRef.current || + transactionThreadReportID || + (Object.keys(allReportTransactions).length !== 1 && !snapshotTransaction) || + !reportMetadata?.hasOnceLoadedReportActions || + reportActions.length === 0 + ) { return; } @@ -306,6 +312,7 @@ function SearchMoneyRequestReportPage({route}: SearchMoneyRequestPageProps) { report, reportActions, reportIDFromRoute, + reportMetadata?.hasOnceLoadedReportActions, reportMetadata?.isLoadingInitialReportActions, snapshot, snapshotTransaction, diff --git a/src/pages/inbox/ReportScreen.tsx b/src/pages/inbox/ReportScreen.tsx index dae370e4d0a52..cea97551c7524 100644 --- a/src/pages/inbox/ReportScreen.tsx +++ b/src/pages/inbox/ReportScreen.tsx @@ -915,7 +915,9 @@ function ReportScreen({route, navigation, isInSidePanel = false}: ReportScreenPr hasCreatedLegacyThreadRef.current || route.name === SCREENS.RIGHT_MODAL.SEARCH_REPORT || transactionThreadReport || - (transactionThreadReportID && transactionThreadReportID !== '0') + (transactionThreadReportID && transactionThreadReportID !== '0') || + !reportMetadata?.hasOnceLoadedReportActions || + reportActions.length === 0 ) { return; } @@ -940,7 +942,19 @@ function ReportScreen({route, navigation, isInSidePanel = false}: ReportScreenPr // For legacy transactions, pass undefined as IOU action and the transaction object // It will be created optimistically and in the backend when call openReport createTransactionThreadReport(introSelected, currentUserEmail ?? '', currentUserAccountID, report, undefined, transaction); - }, [introSelected, currentUserEmail, currentUserAccountID, report, visibleTransactions, transactionThreadReport, transactionThreadReportID, reportID, route.name]); + }, [ + introSelected, + currentUserEmail, + currentUserAccountID, + report, + visibleTransactions, + transactionThreadReport, + transactionThreadReportID, + reportID, + route.name, + reportMetadata?.hasOnceLoadedReportActions, + reportActions.length, + ]); const lastRoute = usePrevious(route);