@@ -141,17 +141,18 @@ function getParticipantEmailsFromReport({sharedReportList, reportNameValuePairs,
141
141
*
142
142
* @param {Object } fullReport
143
143
* @param {String } chatType
144
+ * @param {String } oldPolicyName
144
145
* @return {String }
145
146
*/
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
+
147
154
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' ) } )` : '' } ` ;
155
156
}
156
157
157
158
// For a basic policy room, return its original name
@@ -160,13 +161,10 @@ function getChatReportName(fullReport, chatType) {
160
161
}
161
162
162
163
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' ) } )` : '' } ` ;
170
168
}
171
169
172
170
const { sharedReportList} = fullReport ;
@@ -206,17 +204,17 @@ function getSimplifiedReportObject(report) {
206
204
lastMessageText = ReportUtils . formatReportLastMessageText ( lastMessageText ) ;
207
205
}
208
206
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
+
209
210
const reportName = lodashGet ( report , [ 'reportNameValuePairs' , 'type' ] ) === 'chat'
210
- ? getChatReportName ( report , chatType )
211
+ ? getChatReportName ( report , chatType , oldPolicyName )
211
212
: report . reportName ;
212
213
const lastActorEmail = lodashGet ( report , 'lastActionActorEmail' , '' ) ;
213
214
const notificationPreference = ReportUtils . isChatRoom ( { chatType} )
214
215
? lodashGet ( report , [ 'reportNameValuePairs' , 'notificationPreferences' , currentUserAccountID ] , 'daily' )
215
216
: '' ;
216
217
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
-
220
218
// Used for User Created Policy Rooms, will denote how access to a chat room is given among workspace members
221
219
const visibility = lodashGet ( report , [ 'reportNameValuePairs' , 'visibility' ] ) ;
222
220
0 commit comments