@@ -43,6 +43,7 @@ import type {
43
43
UserWallet ,
44
44
} from '@src/types/onyx' ;
45
45
import type { Participant } from '@src/types/onyx/IOU' ;
46
+ import type { SelectedParticipant } from '@src/types/onyx/NewGroupChatDraft' ;
46
47
import type { OriginalMessageExportedToIntegration } from '@src/types/onyx/OldDotAction' ;
47
48
import type Onboarding from '@src/types/onyx/Onboarding' ;
48
49
import type { Errors , Icon , PendingAction } from '@src/types/onyx/OnyxCommon' ;
@@ -2136,28 +2137,30 @@ function buildParticipantsFromAccountIDs(accountIDs: number[]): Participants {
2136
2137
/**
2137
2138
* Returns the report name if the report is a group chat
2138
2139
*/
2139
- function getGroupChatName ( participantAccountIDs ?: number [ ] , shouldApplyLimit = false , report ?: OnyxEntry < Report > ) : string | undefined {
2140
+ function getGroupChatName ( participants ?: SelectedParticipant [ ] , shouldApplyLimit = false , report ?: OnyxEntry < Report > ) : string | undefined {
2140
2141
// If we have a report always try to get the name from the report.
2141
2142
if ( report ?. reportName ) {
2142
2143
return report . reportName ;
2143
2144
}
2144
2145
2145
- // Get participantAccountIDs from participants object
2146
- let participants = participantAccountIDs ?? Object . keys ( report ?. participants ?? { } ) . map ( Number ) ;
2146
+ let participantAccountIDs = participants ?. map ( ( participant ) => participant . accountID ) ?? Object . keys ( report ?. participants ?? { } ) . map ( Number ) ;
2147
2147
if ( shouldApplyLimit ) {
2148
- participants = participants . slice ( 0 , 5 ) ;
2148
+ participantAccountIDs = participantAccountIDs . slice ( 0 , 5 ) ;
2149
2149
}
2150
- const isMultipleParticipantReport = participants . length > 1 ;
2150
+ const isMultipleParticipantReport = participantAccountIDs . length > 1 ;
2151
2151
2152
2152
if ( isMultipleParticipantReport ) {
2153
- return participants
2154
- . map ( ( participant ) => getDisplayNameForParticipant ( participant , isMultipleParticipantReport ) )
2153
+ return participantAccountIDs
2154
+ . map (
2155
+ ( participantAccountID , index ) =>
2156
+ getDisplayNameForParticipant ( participantAccountID , isMultipleParticipantReport ) || LocalePhoneNumber . formatPhoneNumber ( participants ?. [ index ] ?. login ?? '' ) ,
2157
+ )
2155
2158
. sort ( ( first , second ) => localeCompare ( first ?? '' , second ?? '' ) )
2156
2159
. filter ( Boolean )
2157
2160
. join ( ', ' ) ;
2158
2161
}
2159
2162
2160
- return Localize . translateLocal ( 'groupChat.defaultReportName' , { displayName : getDisplayNameForParticipant ( participants [ 0 ] , false ) } ) ;
2163
+ return Localize . translateLocal ( 'groupChat.defaultReportName' , { displayName : getDisplayNameForParticipant ( participantAccountIDs [ 0 ] , false ) } ) ;
2161
2164
}
2162
2165
2163
2166
function getParticipants ( reportID : string ) {
0 commit comments