Skip to content

fix: no preview message after switching priorities #59252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails
: undefined;
const reportPreviewMessage = getReportPreviewMessage(
!isEmptyObject(iouReport) ? iouReport : null,
lastIOUMoneyReportAction,
lastIOUMoneyReportAction ?? lastReportAction,
true,
reportUtilsIsChatReport(report),
null,
Expand Down
12 changes: 5 additions & 7 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4014,20 +4014,18 @@ 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;
}

const allReportTransactions = getReportTransactions(report.reportID);
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);
Expand Down