Skip to content
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.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ function createOption(logins, personalDetails, report, {
let text;
let alternateText;
if (isChatRoom || isPolicyExpenseChat) {
text = (isArchivedRoom && report.isOwnPolicyExpenseChat) ? report.oldPolicyName : lodashGet(report, ['reportName'], '');
text = lodashGet(report, ['reportName'], '');
alternateText = (showChatPreviewLine && !forcePolicyNamePreview && lastMessageText)
? lastMessageText
: subtitle;
Expand Down
36 changes: 17 additions & 19 deletions src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,18 @@ function getParticipantEmailsFromReport({sharedReportList, reportNameValuePairs,
*
* @param {Object} fullReport
* @param {String} chatType
* @param {String} oldPolicyName
* @return {String}
*/
function getChatReportName(fullReport, chatType) {
function getChatReportName(fullReport, chatType, oldPolicyName) {
const isArchivedRoom = ReportUtils.isArchivedRoom({
chatType,
stateNum: fullReport.state,
statusNum: fullReport.status,
});

if (ReportUtils.isDefaultRoom({chatType})) {
return `#${fullReport.reportName}${(ReportUtils.isArchivedRoom({
chatType,
stateNum: fullReport.state,
statusNum: fullReport.status,
})
? ` (${Localize.translateLocal('common.deleted')})`
: '')}`;
return `#${fullReport.reportName}${isArchivedRoom ? ` (${Localize.translateLocal('common.deleted')})` : ''}`;
}

// For a basic policy room, return its original name
Expand All @@ -160,13 +161,10 @@ function getChatReportName(fullReport, chatType) {
}

if (ReportUtils.isPolicyExpenseChat({chatType})) {
return `${LoginUtils.getEmailWithoutMergedAccountPrefix(fullReport.reportName)}${(ReportUtils.isArchivedRoom({
chatType,
stateNum: fullReport.state,
statusNum: fullReport.status,
})
? ` (${Localize.translateLocal('common.archived')})`
: '')}`;
const name = (isArchivedRoom && fullReport.isOwnPolicyExpenseChat)
? oldPolicyName
: LoginUtils.getEmailWithoutMergedAccountPrefix(lodashGet(fullReport, ['reportName'], ''));
return `${name}${isArchivedRoom ? ` (${Localize.translateLocal('common.archived')})` : ''}`;
}

const {sharedReportList} = fullReport;
Expand Down Expand Up @@ -206,17 +204,17 @@ function getSimplifiedReportObject(report) {
lastMessageText = ReportUtils.formatReportLastMessageText(lastMessageText);
}

// Used for archived rooms, will store the policy name that the room used to belong to.
const oldPolicyName = lodashGet(report, ['reportNameValuePairs', 'oldPolicyName'], '');

const reportName = lodashGet(report, ['reportNameValuePairs', 'type']) === 'chat'
? getChatReportName(report, chatType)
? getChatReportName(report, chatType, oldPolicyName)
: report.reportName;
const lastActorEmail = lodashGet(report, 'lastActionActorEmail', '');
const notificationPreference = ReportUtils.isChatRoom({chatType})
? lodashGet(report, ['reportNameValuePairs', 'notificationPreferences', currentUserAccountID], 'daily')
: '';

// Used for archived rooms, will store the policy name that the room used to belong to.
const oldPolicyName = lodashGet(report, ['reportNameValuePairs', 'oldPolicyName'], '');

// Used for User Created Policy Rooms, will denote how access to a chat room is given among workspace members
const visibility = lodashGet(report, ['reportNameValuePairs', 'visibility']);

Expand Down