diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 5bf53a507b4a..0677da5b5fc5 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -412,10 +412,9 @@ function getLastMessageTextForReport(report) { * @param {Object} options * @param {Boolean} [options.showChatPreviewLine] * @param {Boolean} [options.forcePolicyNamePreview] - * @param {Boolean} [options.checkPolicyOwner] * @returns {Object} */ -function createOption(accountIDs, personalDetails, report, reportActions = {}, {showChatPreviewLine = false, forcePolicyNamePreview = false, checkPolicyOwner = true}) { +function createOption(accountIDs, personalDetails, report, reportActions = {}, {showChatPreviewLine = false, forcePolicyNamePreview = false}) { const result = { text: null, alternateText: null, @@ -486,7 +485,7 @@ function createOption(accountIDs, personalDetails, report, reportActions = {}, { result.policyID = report.policyID; hasMultipleParticipants = personalDetailList.length > 1 || result.isChatRoom || result.isPolicyExpenseChat; - subtitle = ReportUtils.getChatRoomSubtitle(report, checkPolicyOwner); + subtitle = ReportUtils.getChatRoomSubtitle(report); const lastMessageTextFromReport = getLastMessageTextForReport(report); const lastActorDetails = personalDetailMap[report.lastActorAccountID] || null; @@ -512,12 +511,7 @@ function createOption(accountIDs, personalDetails, report, reportActions = {}, { } else { result.alternateText = showChatPreviewLine && lastMessageText ? lastMessageText : LocalePhoneNumber.formatPhoneNumber(personalDetail.login); } - - if (result.isPolicyExpenseChat && !checkPolicyOwner) { - reportName = ReportUtils.getPolicyName(report); - } else { - reportName = ReportUtils.getReportName(report); - } + reportName = ReportUtils.getReportName(report); } else { reportName = ReportUtils.getDisplayNameForParticipant(accountIDs[0]); result.keyForList = String(accountIDs[0]); @@ -557,9 +551,10 @@ function getPolicyExpenseReportOption(report) { { showChatPreviewLine: false, forcePolicyNamePreview: false, - checkPolicyOwner: false, }, ); + option.text = ReportUtils.getPolicyName(report); + option.alternateText = Localize.translateLocal('workspace.common.workspace'); option.selected = report.selected; return option; } diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 0e53200db486..8bb67d639486 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1859,10 +1859,9 @@ function getRootReportAndWorkspaceName(report) { /** * Get either the policyName or domainName the chat is tied to * @param {Object} report - * @param {Boolean} checkPolicyOwner * @returns {String} */ -function getChatRoomSubtitle(report, checkPolicyOwner = true) { +function getChatRoomSubtitle(report) { if (isChatThread(report)) { return ''; } @@ -1873,7 +1872,7 @@ function getChatRoomSubtitle(report, checkPolicyOwner = true) { // The domainAll rooms are just #domainName, so we ignore the prefix '#' to get the domainName return report.reportName.substring(1); } - if ((isPolicyExpenseChat(report) && (!checkPolicyOwner || report.isOwnPolicyExpenseChat)) || isExpenseReport(report)) { + if ((isPolicyExpenseChat(report) && report.isOwnPolicyExpenseChat) || isExpenseReport(report)) { return Localize.translateLocal('workspace.common.workspace'); } if (isArchivedRoom(report)) {