Skip to content

Commit 8665582

Browse files
authored
Merge pull request #8751 from Expensify/amal-fix-archived-member-view
Fix mismatched names for archived policyExpenseChats that the user owns
2 parents 16b130b + 728e933 commit 8665582

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

src/libs/OptionsListUtils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ function createOption(logins, personalDetails, report, {
231231
let text;
232232
let alternateText;
233233
if (isChatRoom || isPolicyExpenseChat) {
234-
text = (isArchivedRoom && report.isOwnPolicyExpenseChat) ? report.oldPolicyName : lodashGet(report, ['reportName'], '');
234+
text = lodashGet(report, ['reportName'], '');
235235
alternateText = (showChatPreviewLine && !forcePolicyNamePreview && lastMessageText)
236236
? lastMessageText
237237
: subtitle;

src/libs/actions/Report.js

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,18 @@ function getParticipantEmailsFromReport({sharedReportList, reportNameValuePairs,
141141
*
142142
* @param {Object} fullReport
143143
* @param {String} chatType
144+
* @param {String} oldPolicyName
144145
* @return {String}
145146
*/
146-
function getChatReportName(fullReport, chatType) {
147+
function getChatReportName(fullReport, chatType, oldPolicyName) {
148+
const isArchivedRoom = ReportUtils.isArchivedRoom({
149+
chatType,
150+
stateNum: fullReport.state,
151+
statusNum: fullReport.status,
152+
});
153+
147154
if (ReportUtils.isDefaultRoom({chatType})) {
148-
return `#${fullReport.reportName}${(ReportUtils.isArchivedRoom({
149-
chatType,
150-
stateNum: fullReport.state,
151-
statusNum: fullReport.status,
152-
})
153-
? ` (${Localize.translateLocal('common.deleted')})`
154-
: '')}`;
155+
return `#${fullReport.reportName}${isArchivedRoom ? ` (${Localize.translateLocal('common.deleted')})` : ''}`;
155156
}
156157

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

162163
if (ReportUtils.isPolicyExpenseChat({chatType})) {
163-
return `${LoginUtils.getEmailWithoutMergedAccountPrefix(fullReport.reportName)}${(ReportUtils.isArchivedRoom({
164-
chatType,
165-
stateNum: fullReport.state,
166-
statusNum: fullReport.status,
167-
})
168-
? ` (${Localize.translateLocal('common.archived')})`
169-
: '')}`;
164+
const name = (isArchivedRoom && fullReport.isOwnPolicyExpenseChat)
165+
? oldPolicyName
166+
: LoginUtils.getEmailWithoutMergedAccountPrefix(lodashGet(fullReport, ['reportName'], ''));
167+
return `${name}${isArchivedRoom ? ` (${Localize.translateLocal('common.archived')})` : ''}`;
170168
}
171169

172170
const {sharedReportList} = fullReport;
@@ -206,17 +204,17 @@ function getSimplifiedReportObject(report) {
206204
lastMessageText = ReportUtils.formatReportLastMessageText(lastMessageText);
207205
}
208206

207+
// Used for archived rooms, will store the policy name that the room used to belong to.
208+
const oldPolicyName = lodashGet(report, ['reportNameValuePairs', 'oldPolicyName'], '');
209+
209210
const reportName = lodashGet(report, ['reportNameValuePairs', 'type']) === 'chat'
210-
? getChatReportName(report, chatType)
211+
? getChatReportName(report, chatType, oldPolicyName)
211212
: report.reportName;
212213
const lastActorEmail = lodashGet(report, 'lastActionActorEmail', '');
213214
const notificationPreference = ReportUtils.isChatRoom({chatType})
214215
? lodashGet(report, ['reportNameValuePairs', 'notificationPreferences', currentUserAccountID], 'daily')
215216
: '';
216217

217-
// Used for archived rooms, will store the policy name that the room used to belong to.
218-
const oldPolicyName = lodashGet(report, ['reportNameValuePairs', 'oldPolicyName'], '');
219-
220218
// Used for User Created Policy Rooms, will denote how access to a chat room is given among workspace members
221219
const visibility = lodashGet(report, ['reportNameValuePairs', 'visibility']);
222220

0 commit comments

Comments
 (0)