diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 32972a81bcb5..4c1213876466 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -225,7 +225,7 @@ function isTransactionThread(parentReportAction: OnyxEntry | Empty /** * Returns the reportID for the transaction thread associated with a report by iterating over the reportActions and identifying the IOU report actions with a childReportID. Returns a reportID if there is exactly one transaction thread for the report, and null otherwise. */ -function getOneTransactionThreadReportID(reportID: string, reportActions: OnyxEntry | ReportAction[]): string | null { +function getOneTransactionThreadReportID(reportID: string, reportActions: OnyxEntry | ReportAction[], isOffline: boolean | undefined = undefined): string | null { // If the report is not an IOU or Expense report, it shouldn't be treated as one-transaction report. const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; if (report?.type !== CONST.REPORT.TYPE.IOU && report?.type !== CONST.REPORT.TYPE.EXPENSE) { @@ -250,7 +250,7 @@ function getOneTransactionThreadReportID(reportID: string, reportActions: OnyxEn action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && (iouRequestTypes.includes(action.originalMessage.type) ?? []) && action.childReportID && - action.originalMessage.IOUTransactionID, + (Boolean(action.originalMessage.IOUTransactionID) || (action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE && (isOffline ?? isNetworkOffline))), ); // If we don't have any IOU request actions, or we have more than one IOU request actions, this isn't a oneTransaction report diff --git a/src/pages/home/ReportScreen.tsx b/src/pages/home/ReportScreen.tsx index 332e9b080558..1854afb961ed 100644 --- a/src/pages/home/ReportScreen.tsx +++ b/src/pages/home/ReportScreen.tsx @@ -22,6 +22,7 @@ import type {CurrentReportIDContextValue} from '@components/withCurrentReportID' import withCurrentReportID from '@components/withCurrentReportID'; import useAppFocusEvent from '@hooks/useAppFocusEvent'; import useLocalize from '@hooks/useLocalize'; +import useNetwork from '@hooks/useNetwork'; import usePrevious from '@hooks/usePrevious'; import useThemeStyles from '@hooks/useThemeStyles'; import useViewportOffsetTop from '@hooks/useViewportOffsetTop'; @@ -157,6 +158,7 @@ function ReportScreen({ const firstRenderRef = useRef(true); const flatListRef = useRef(null); const reactionListRef = useRef(null); + const {isOffline} = useNetwork(); /** * Create a lightweight Report so as to keep the re-rendering as light as possible by * passing in only the required props. @@ -334,7 +336,10 @@ function ReportScreen({ ); } - const transactionThreadReportID = useMemo(() => ReportActionsUtils.getOneTransactionThreadReportID(report.reportID, reportActions ?? []), [report.reportID, reportActions]); + const transactionThreadReportID = useMemo( + () => ReportActionsUtils.getOneTransactionThreadReportID(report.reportID, reportActions ?? [], isOffline), + [report.reportID, reportActions, isOffline], + ); useEffect(() => { if (!transactionThreadReportID || !route.params.reportActionID) {