Skip to content

Commit

Permalink
perf: use only first 5 other participants to generate a title for a R…
Browse files Browse the repository at this point in the history
…eport
  • Loading branch information
jbroma committed Mar 6, 2024
1 parent a8ece90 commit 5c24359
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2611,11 +2611,13 @@ function getReportName(report: OnyxEntry<Report>, policy: OnyxEntry<Policy> = nu
return formattedName;
}

// Not a room or PolicyExpenseChat, generate title from participants
const participantAccountIDs = report?.participantAccountIDs ?? [];
// Not a room or PolicyExpenseChat, generate title from first 5 other participants
const participantAccountIDs = report?.participantAccountIDs?.slice(0, 6) ?? [];
const participantsWithoutCurrentUser = participantAccountIDs.filter((accountID) => accountID !== currentUserAccountID);
const isMultipleParticipantReport = participantsWithoutCurrentUser.length > 1;

if (participantsWithoutCurrentUser.length > 5) {
participantsWithoutCurrentUser.pop();
}
return participantsWithoutCurrentUser.map((accountID) => getDisplayNameForParticipant(accountID, isMultipleParticipantReport)).join(', ');
}

Expand Down

0 comments on commit 5c24359

Please sign in to comment.