Skip to content

Commit

Permalink
fix: further optimization of getDisplayNameForParticipant
Browse files Browse the repository at this point in the history
  • Loading branch information
OlimpiaZurek committed Jul 26, 2024
1 parent aaa03bd commit 800423b
Showing 1 changed file with 8 additions and 1 deletion.
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

0 comments on commit 800423b

Please sign in to comment.