Skip to content

Commit

Permalink
refactor: remove not needed variable
Browse files Browse the repository at this point in the history
  • Loading branch information
hurali97 committed Mar 11, 2024
1 parent 99dd34c commit 3ff2f9c
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/libs/PersonalDetailsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,19 @@ Onyx.connect({
},
});

// Index for the substring method to remove the merged account prefix.
const substringStartIndex = CONST.MERGED_ACCOUNT_PREFIX.length;

function getDisplayNameOrDefault(passedPersonalDetails?: Partial<PersonalDetails> | null, defaultValue = '', shouldFallbackToHidden = true, shouldAddCurrentUserPostfix = false): string {
let displayName = passedPersonalDetails?.displayName ?? '';

// If the displayName starts with the merged account prefix, remove it.
if (displayName.startsWith(CONST.MERGED_ACCOUNT_PREFIX)) {
displayName = displayName.substring(substringStartIndex);
// Remove the merged account prefix from the displayName.
displayName = displayName.substring(CONST.MERGED_ACCOUNT_PREFIX.length);
}

if (shouldAddCurrentUserPostfix && !!displayName) {
displayName = `${displayName} (${Localize.translateLocal('common.you').toLowerCase()})`;
}

// If displayName exists, return it early so we don't have to allocate
// memory for the fallback string.
if (displayName) {
return displayName;
}
Expand Down

0 comments on commit 3ff2f9c

Please sign in to comment.