Skip to content

Commit

Permalink
Merge pull request #44109 from allgandalf/fix-issue42677
Browse files Browse the repository at this point in the history
Update Workspace auto naming to include using First Name over the username of a public email
  • Loading branch information
chiragsalian authored Jul 16, 2024
2 parents 5991b8b + fee8c12 commit 825821b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import getIsNarrowLayout from '@libs/getIsNarrowLayout';
import Log from '@libs/Log';
import * as NetworkStore from '@libs/Network/NetworkStore';
import * as NumberUtils from '@libs/NumberUtils';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
import * as PhoneNumber from '@libs/PhoneNumber';
import * as PolicyUtils from '@libs/PolicyUtils';
import {navigateWhenEnableFeature} from '@libs/PolicyUtils';
Expand Down Expand Up @@ -1306,11 +1307,17 @@ function generateDefaultWorkspaceName(email = ''): string {
}
const username = emailParts[0];
const domain = emailParts[1];
const userDetails = PersonalDetailsUtils.getPersonalDetailByEmail(sessionEmail);
const displayName = userDetails?.displayName?.trim();

if (PUBLIC_DOMAINS.some((publicDomain) => publicDomain === domain.toLowerCase())) {
if (!PUBLIC_DOMAINS.some((publicDomain) => publicDomain === domain.toLowerCase())) {
defaultWorkspaceName = `${Str.UCFirst(domain.split('.')[0])}'s Workspace`;
} else if (displayName) {
defaultWorkspaceName = `${Str.UCFirst(displayName)}'s Workspace`;
} else if (PUBLIC_DOMAINS.some((publicDomain) => publicDomain === domain.toLowerCase())) {
defaultWorkspaceName = `${Str.UCFirst(username)}'s Workspace`;
} else {
defaultWorkspaceName = `${Str.UCFirst(domain.split('.')[0])}'s Workspace`;
defaultWorkspaceName = userDetails?.phoneNumber ?? '';
}

if (`@${domain.toLowerCase()}` === CONST.SMS.DOMAIN) {
Expand Down

0 comments on commit 825821b

Please sign in to comment.