diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index c07da3e53973..e7600386945a 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4861,15 +4861,15 @@ function getReportNameInternal({ if (isArchivedNonExpenseReport(report, getReportNameValuePairs(report?.reportID, reportNameValuePairs))) { formattedName += ` (${translateLocal('common.archived')})`; } - return formatReportLastMessageText(formattedName); + return formatReportLastMessageText(formattedName) ?? report?.reportName ?? ''; } if (!isEmptyObject(parentReportAction) && isOldDotReportAction(parentReportAction)) { - return getMessageOfOldDotReportAction(parentReportAction); + return getMessageOfOldDotReportAction(parentReportAction) ?? report?.reportName ?? ''; } if (isRenamedAction(parentReportAction)) { - return getRenamedAction(parentReportAction, isExpenseReport(getReport(report.parentReportID, allReports))); + return getRenamedAction(parentReportAction, isExpenseReport(getReport(report.parentReportID, allReports))) ?? report?.reportName ?? ''; } if (parentReportActionMessage?.isDeletedParentAction) { @@ -4899,7 +4899,7 @@ function getReportNameInternal({ return translateLocal('parentReportAction.hiddenMessage'); } if (isAdminRoom(report) || isUserCreatedPolicyRoom(report)) { - return getAdminRoomInvitedParticipants(parentReportAction, reportActionMessage); + return getAdminRoomInvitedParticipants(parentReportAction, reportActionMessage) ?? report?.reportName ?? ''; } // This will get removed as part of https://github.com/Expensify/App/issues/59961 @@ -4909,15 +4909,15 @@ function getReportNameInternal({ } if (!isEmptyObject(parentReportAction) && isModifiedExpenseAction(parentReportAction)) { const modifiedMessage = ModifiedExpenseMessage.getForReportAction({reportOrID: report?.reportID, reportAction: parentReportAction, searchReports: reports}); - return formatReportLastMessageText(modifiedMessage); + return formatReportLastMessageText(modifiedMessage) ?? report?.reportName ?? ''; } if (isTripRoom(report) && report?.reportName !== CONST.REPORT.DEFAULT_REPORT_NAME) { return report?.reportName ?? ''; } if (isCardIssuedAction(parentReportAction)) { - return getCardIssuedMessage({reportAction: parentReportAction}); + return getCardIssuedMessage({reportAction: parentReportAction}) ?? report?.reportName ?? ''; } - return reportActionMessage; + return reportActionMessage ?? report?.reportName ?? ''; } if (isClosedExpenseReportWithNoExpenses(report, transactions)) { @@ -4925,7 +4925,7 @@ function getReportNameInternal({ } if (isGroupChat(report)) { - return getGroupChatName(undefined, true, report) ?? ''; + return getGroupChatName(undefined, true, report) ?? report?.reportName ?? ''; } if (isChatRoom(report)) { @@ -4959,13 +4959,13 @@ function getReportNameInternal({ } if (formattedName) { - return formatReportLastMessageText(formattedName); + return formatReportLastMessageText(formattedName) ?? report?.reportName ?? ''; } // Not a room or PolicyExpenseChat, generate title from first 5 other participants formattedName = buildReportNameFromParticipantNames({report, personalDetails}); - return formattedName; + return formattedName ?? report?.reportName ?? ''; } /** @@ -5782,18 +5782,15 @@ function getDeletedTransactionMessage(action: ReportAction) { return message; } -function getReportDetails(reportID: string): {reportName: string; reportUrl: string} { - const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; - return { - reportName: getReportName(report) ?? report?.reportName ?? '', - reportUrl: `${environmentURL}/r/${reportID}`, - }; +function getReportUrl(reportID: string) { + return `${environmentURL}/r/${reportID}`; } -function getMovedTransactionMessage(action: ReportAction) { +function getMovedTransactionMessage(action: ReportAction, parentReportAction: OnyxEntry, report?: Report) { const movedTransactionOriginalMessage = getOriginalMessage(action as ReportAction) ?? {}; const {toReportID} = movedTransactionOriginalMessage as OriginalMessageMovedTransaction; - const {reportName, reportUrl} = getReportDetails(toReportID); + const reportName = getReportName(report, undefined, parentReportAction); + const reportUrl = getReportUrl(toReportID); const message = translateLocal('iou.movedTransaction', { reportUrl, reportName, diff --git a/src/pages/home/report/PureReportActionItem.tsx b/src/pages/home/report/PureReportActionItem.tsx index 1636e69a2b3d..1e05c6502010 100644 --- a/src/pages/home/report/PureReportActionItem.tsx +++ b/src/pages/home/report/PureReportActionItem.tsx @@ -1053,7 +1053,7 @@ function PureReportActionItem({ } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.MOVED_TRANSACTION) { children = ( - ${getMovedTransactionMessage(action)}`} /> + ${getMovedTransactionMessage(action, parentReportAction, report)}`} /> ); } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.UNREPORTED_TRANSACTION) {