diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index 6c9b105e1d38..04413d6e40b0 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -9,6 +9,7 @@ import CONST from '../CONST'; import * as ReportUtils from './reportUtils'; import * as Localize from './Localize'; import Permissions from './Permissions'; +import * as CollectionUtils from './CollectionUtils'; /** * OptionsListUtils is used to build a list options passed to the OptionsList component. Several different UI views can @@ -76,6 +77,18 @@ Onyx.connect({ }, }); +const lastReportActions = {}; +Onyx.connect({ + key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, + callback: (actions, key) => { + if (!key || !actions) { + return; + } + const reportID = CollectionUtils.extractCollectionItemID(key); + lastReportActions[reportID] = _.last(_.toArray(actions)); + }, +}); + // We are initializing a default avatar here so that we use the same default color for each user we are inviting. This // will update when the OptionsListUtils re-loads. But will stay the same color for the life of the JS session. const defaultAvatarForUserToInvite = ReportUtils.getDefaultAvatar(); @@ -221,11 +234,19 @@ function createOption(logins, personalDetails, report, { const lastMessageTextFromReport = ReportUtils.isReportMessageAttachment({text: lodashGet(report, 'lastMessageText', ''), html: lodashGet(report, 'lastMessageHtml', '')}) ? `[${Localize.translateLocal('common.attachment')}]` : Str.htmlDecode(lodashGet(report, 'lastMessageText', '')); - let lastMessageText = report && !isArchivedRoom && hasMultipleParticipants && lastActorDetails + let lastMessageText = report && hasMultipleParticipants && lastActorDetails ? `${lastActorDetails.displayName}: ` : ''; lastMessageText += report ? lastMessageTextFromReport : ''; + if (isPolicyExpenseChat && isArchivedRoom) { + const archiveReason = lodashGet(lastReportActions[report.reportID], 'originalMessage.reason', CONST.REPORT.ARCHIVE_REASON.DEFAULT); + lastMessageText = Localize.translate(preferredLocale, `reportArchiveReasons.${archiveReason}`, { + displayName: lastActorDetails.displayName, + policyName: ReportUtils.getPolicyName(report, policies), + }); + } + const tooltipText = ReportUtils.getReportParticipantsTitle(lodashGet(report, ['participants'], [])); const subtitle = ReportUtils.getChatRoomSubtitle(report, policies); let text; @@ -270,7 +291,7 @@ function createOption(logins, personalDetails, report, { iouReportAmount: lodashGet(iouReport, 'total', 0), isChatRoom, isArchivedRoom, - shouldShowSubscript: isPolicyExpenseChat && !report.isOwnPolicyExpenseChat, + shouldShowSubscript: isPolicyExpenseChat && !report.isOwnPolicyExpenseChat && !isArchivedRoom, isPolicyExpenseChat, }; } diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index 7231bdccd31e..b01adba833b4 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -100,7 +100,7 @@ const HeaderView = (props) => { // these users via alternative means. It is possible to request a call with Concierge so we leave the option for them. const shouldShowCallButton = isConcierge || !isAutomatedExpensifyAccount; const avatarTooltip = isChatRoom ? undefined : _.pluck(displayNamesWithTooltips, 'tooltip'); - const shouldShowSubscript = isPolicyExpenseChat && !props.report.isOwnPolicyExpenseChat; + const shouldShowSubscript = isPolicyExpenseChat && !props.report.isOwnPolicyExpenseChat && !ReportUtils.isArchivedRoom(props.report); const icons = ReportUtils.getIcons(props.report, props.personalDetails, props.policies); return (