Skip to content

Commit

Permalink
Merge pull request Expensify#53540 from daledah/fix/51934
Browse files Browse the repository at this point in the history
fix: some member appear as Hidden
  • Loading branch information
thienlnam authored Dec 23, 2024
2 parents e85dc90 + 5950c11 commit eebf550
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/libs/PersonalDetailsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const regexMergedAccount = new RegExp(CONST.REGEX.MERGED_ACCOUNT_PREFIX);
function getDisplayNameOrDefault(passedPersonalDetails?: Partial<PersonalDetails> | null, defaultValue = '', shouldFallbackToHidden = true, shouldAddCurrentUserPostfix = false): string {
let displayName = passedPersonalDetails?.displayName ?? '';

let login = passedPersonalDetails?.login ?? '';

// If the displayName starts with the merged account prefix, remove it.
if (regexMergedAccount.test(displayName)) {
// Remove the merged account prefix from the displayName.
Expand All @@ -60,8 +62,11 @@ function getDisplayNameOrDefault(passedPersonalDetails?: Partial<PersonalDetails

// If the displayName is not set by the user, the backend sets the diplayName same as the login so
// we need to remove the sms domain from the displayName if it is an sms login.
if (displayName === passedPersonalDetails?.login && Str.isSMSLogin(passedPersonalDetails?.login)) {
displayName = Str.removeSMSDomain(displayName);
if (Str.isSMSLogin(login)) {
if (displayName === login) {
displayName = Str.removeSMSDomain(displayName);
}
login = Str.removeSMSDomain(login);
}

if (shouldAddCurrentUserPostfix && !!displayName) {
Expand All @@ -75,7 +80,16 @@ function getDisplayNameOrDefault(passedPersonalDetails?: Partial<PersonalDetails
if (displayName) {
return displayName;
}
return defaultValue || (shouldFallbackToHidden ? hiddenTranslation : '');

if (defaultValue) {
return defaultValue;
}

if (login) {
return login;
}

return shouldFallbackToHidden ? hiddenTranslation : '';
}

/**
Expand Down

0 comments on commit eebf550

Please sign in to comment.