Skip to content

Commit c70bc0c

Browse files
Merge pull request #59252 from mustafapsd/fix-switch-priority-last-message-preview
fix: no preview message after switching priorities
2 parents ade1a90 + 10c3dfb commit c70bc0c

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/libs/OptionsListUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ function getLastMessageTextForReport(report: OnyxEntry<Report>, lastActorDetails
713713
: undefined;
714714
const reportPreviewMessage = getReportPreviewMessage(
715715
!isEmptyObject(iouReport) ? iouReport : null,
716-
lastIOUMoneyReportAction,
716+
lastIOUMoneyReportAction ?? lastReportAction,
717717
true,
718718
reportUtilsIsChatReport(report),
719719
null,

src/libs/ReportUtils.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4048,20 +4048,18 @@ function getReportPreviewMessage(
40484048
const report = typeof reportOrID === 'string' ? getReport(reportOrID, allReports) : reportOrID;
40494049
const reportActionMessage = getReportActionHtml(iouReportAction);
40504050

4051-
if (!report?.reportID) {
4051+
if (isEmptyObject(report) || !report?.reportID) {
4052+
// This iouReport may be unavailable for one of the following reasons:
4053+
// 1. After SignIn, the OpenApp API won't return iouReports if they're settled.
4054+
// 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.
4055+
// Until we know how to solve this the best, we just display the report action message.
40524056
return reportActionMessage;
40534057
}
40544058

40554059
const allReportTransactions = getReportTransactions(report.reportID);
40564060
const transactionsWithReceipts = allReportTransactions.filter(hasReceiptTransactionUtils);
40574061
const numberOfScanningReceipts = transactionsWithReceipts.filter(isReceiptBeingScanned).length;
40584062

4059-
if (isEmptyObject(report) || !report?.reportID) {
4060-
// The iouReport is not found locally after SignIn because the OpenApp API won't return iouReports if they're settled
4061-
// As a temporary solution until we know how to solve this the best, we just use the message that returned from BE
4062-
return reportActionMessage;
4063-
}
4064-
40654063
if (!isEmptyObject(iouReportAction) && !isIOUReport(report) && iouReportAction && isSplitBillReportAction(iouReportAction)) {
40664064
// This covers group chats where the last action is a split expense action
40674065
const linkedTransaction = getLinkedTransaction(iouReportAction);

0 commit comments

Comments
 (0)