Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: further optimization of getDisplayNameForParticipant #46282

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,13 @@ function getPersonalDetailsForAccountID(accountID: number): Partial<PersonalDeta
return allPersonalDetails?.[accountID] ?? defaultDetails;
}

/**
* Returns the personal details or a default object if the personal details are not available.
*/
function getPersonalDetailsOrDefault(personalDetails: Partial<PersonalDetails> | undefined | null): Partial<PersonalDetails> {
return personalDetails ?? {isOptimisticPersonalDetail: true};
}

const hiddenTranslation = Localize.translateLocal('common.hidden');

const phoneNumberCache: Record<string, string> = {};
Expand All @@ -1909,7 +1916,7 @@ function getDisplayNameForParticipant(accountID?: number, shouldUseShortForm = f
return '';
}

const personalDetails = getPersonalDetailsForAccountID(accountID);
const personalDetails = getPersonalDetailsOrDefault(allPersonalDetails?.[accountID]);
if (!personalDetails) {
return '';
}
Expand Down
Loading