@@ -2700,9 +2700,15 @@ function getDisplayNameForParticipant({
27002700 return shouldUseShortForm ? shortName : longName ;
27012701}
27022702
2703- function getParticipantsAccountIDsForDisplay ( report : OnyxEntry < Report > , shouldExcludeHidden = false , shouldExcludeDeleted = false , shouldForceExcludeCurrentUser = false ) : number [ ] {
2703+ function getParticipantsAccountIDsForDisplay (
2704+ report : OnyxEntry < Report > ,
2705+ shouldExcludeHidden = false ,
2706+ shouldExcludeDeleted = false ,
2707+ shouldForceExcludeCurrentUser = false ,
2708+ reportMetadataParam ?: OnyxEntry < ReportMetadata > ,
2709+ ) : number [ ] {
27042710 const reportParticipants = report ?. participants ?? { } ;
2705- const reportMetadata = getReportMetadata ( report ?. reportID ) ;
2711+ const reportMetadata = reportMetadataParam ?? getReportMetadata ( report ?. reportID ) ;
27062712 let participantsEntries = Object . entries ( reportParticipants ) ;
27072713
27082714 // We should not show participants that have an optimistic entry with the same login in the personal details
@@ -2797,13 +2803,13 @@ function buildParticipantsFromAccountIDs(accountIDs: number[]): Participants {
27972803/**
27982804 * Returns the report name if the report is a group chat
27992805 */
2800- function getGroupChatName ( participants ?: SelectedParticipant [ ] , shouldApplyLimit = false , report ?: OnyxEntry < Report > ) : string | undefined {
2806+ function getGroupChatName ( participants ?: SelectedParticipant [ ] , shouldApplyLimit = false , report ?: OnyxEntry < Report > , reportMetadataParam ?: OnyxEntry < ReportMetadata > ) : string | undefined {
28012807 // If we have a report always try to get the name from the report.
28022808 if ( report ?. reportName ) {
28032809 return report . reportName ;
28042810 }
28052811
2806- const reportMetadata = getReportMetadata ( report ?. reportID ) ;
2812+ const reportMetadata = reportMetadataParam ?? getReportMetadata ( report ?. reportID ) ;
28072813
28082814 const pendingMemberAccountIDs = new Set (
28092815 reportMetadata ?. pendingChatMembers ?. filter ( ( member ) => member . pendingAction === CONST . RED_BRICK_ROAD_PENDING_ACTION . DELETE ) . map ( ( member ) => member . accountID ) ,
@@ -4595,12 +4601,14 @@ function getReportName(
45954601 parentReportActionParam ?: OnyxInputOrEntry < ReportAction > ,
45964602 personalDetails ?: Partial < PersonalDetailsList > ,
45974603 invoiceReceiverPolicy ?: OnyxEntry < Policy > ,
4604+ reportAttributesParam ?: ReportAttributesDerivedValue [ 'reports' ] ,
45984605) : string {
45994606 // Check if we can use report name in derived values - only when we have report but no other params
46004607 const canUseDerivedValue = report && policy === undefined && parentReportActionParam === undefined && personalDetails === undefined && invoiceReceiverPolicy === undefined ;
4601- const derivedNameExists = report && ! ! reportAttributes ?. [ report . reportID ] ?. reportName ;
4608+ const attributes = reportAttributesParam ?? reportAttributes ;
4609+ const derivedNameExists = report && ! ! attributes ?. [ report . reportID ] ?. reportName ;
46024610 if ( canUseDerivedValue && derivedNameExists ) {
4603- return reportAttributes [ report . reportID ] . reportName ;
4611+ return attributes [ report . reportID ] . reportName ;
46044612 }
46054613 return getReportNameInternal ( { report, policy, parentReportActionParam, personalDetails, invoiceReceiverPolicy} ) ;
46064614}
0 commit comments