Skip to content

Commit

Permalink
Merge pull request #8751 from Expensify/amal-fix-archived-member-view
Browse files Browse the repository at this point in the history
Fix mismatched names for archived policyExpenseChats that the user owns
  • Loading branch information
amyevans authored Apr 25, 2022
2 parents 16b130b + 728e933 commit 8665582
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
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

0 comments on commit 8665582

Please sign in to comment.