diff --git a/src/libs/OptionsListUtils.ts b/src/libs/OptionsListUtils.ts index 9f5b061cba41..22382a4bff39 100644 --- a/src/libs/OptionsListUtils.ts +++ b/src/libs/OptionsListUtils.ts @@ -695,7 +695,7 @@ function getLastMessageTextForReport(report: OnyxEntry, lastActorDetails : undefined; const reportPreviewMessage = getReportPreviewMessage( !isEmptyObject(iouReport) ? iouReport : null, - lastIOUMoneyReportAction, + lastIOUMoneyReportAction ?? lastReportAction, true, reportUtilsIsChatReport(report), null, diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 8d421fca3ea9..fd365510109d 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4014,7 +4014,11 @@ function getReportPreviewMessage( const report = typeof reportOrID === 'string' ? getReport(reportOrID, allReports) : reportOrID; const reportActionMessage = getReportActionHtml(iouReportAction); - if (!report?.reportID) { + if (isEmptyObject(report) || !report?.reportID) { + // This iouReport may be unavailable for one of the following reasons: + // 1. After SignIn, the OpenApp API won't return iouReports if they're settled. + // 2. The iouReport exists in local storage but hasn't been loaded into the allReports. It will be loaded automatically when the user opens the iouReport. + // Until we know how to solve this the best, we just display the report action message. return reportActionMessage; } @@ -4022,12 +4026,6 @@ function getReportPreviewMessage( const transactionsWithReceipts = allReportTransactions.filter(hasReceiptTransactionUtils); const numberOfScanningReceipts = transactionsWithReceipts.filter(isReceiptBeingScanned).length; - if (isEmptyObject(report) || !report?.reportID) { - // The iouReport is not found locally after SignIn because the OpenApp API won't return iouReports if they're settled - // As a temporary solution until we know how to solve this the best, we just use the message that returned from BE - return reportActionMessage; - } - if (!isEmptyObject(iouReportAction) && !isIOUReport(report) && iouReportAction && isSplitBillReportAction(iouReportAction)) { // This covers group chats where the last action is a split expense action const linkedTransaction = getLinkedTransaction(iouReportAction);