@@ -1674,12 +1674,13 @@ function generateDefaultWorkspaceName(email = ''): string {
16741674 displayNameForWorkspace = userDetails ?. phoneNumber ?? '' ;
16751675 }
16761676
1677- if ( `@${ domain } ` === CONST . SMS . DOMAIN ) {
1678- return translateLocal ( 'workspace.new.myGroupWorkspace' ) ;
1677+ const isSMSDomain = `@${ domain } ` === CONST . SMS . DOMAIN ;
1678+ if ( isSMSDomain ) {
1679+ displayNameForWorkspace = translateLocal ( 'workspace.new.myGroupWorkspace' , { } ) ;
16791680 }
16801681
16811682 if ( isEmptyObject ( allPolicies ) ) {
1682- return translateLocal ( 'workspace.new.workspaceName' , { userName : displayNameForWorkspace } ) ;
1683+ return isSMSDomain ? translateLocal ( 'workspace.new.myGroupWorkspace' , { } ) : translateLocal ( 'workspace.new.workspaceName' , { userName : displayNameForWorkspace } ) ;
16831684 }
16841685
16851686 // find default named workspaces and increment the last number
@@ -1688,14 +1689,17 @@ function generateDefaultWorkspaceName(email = ''): string {
16881689 . map ( ( lang ) => translate ( lang , 'workspace.common.workspace' ) )
16891690 . join ( '|' ) ;
16901691
1691- const workspaceRegex = new RegExp ( `^(?=.*${ escapedName } )(?:.*(?:${ workspaceTranslations } )\\s*(\\d+)?)` , 'i' ) ;
1692+ const workspaceRegex = isSMSDomain ? new RegExp ( `^ ${ escapedName } \\s*(\\d+)?$` , 'i' ) : new RegExp ( `^(?=.*${ escapedName } )(?:.*(?:${ workspaceTranslations } )\\s*(\\d+)?)` , 'i' ) ;
16921693
16931694 const workspaceNumbers = Object . values ( allPolicies )
16941695 . map ( ( policy ) => workspaceRegex . exec ( policy ?. name ?? '' ) )
16951696 . filter ( Boolean ) // Remove null matches
16961697 . map ( ( match ) => Number ( match ?. [ 1 ] ?? '0' ) ) ;
16971698 const lastWorkspaceNumber = workspaceNumbers . length > 0 ? Math . max ( ...workspaceNumbers ) : undefined ;
16981699
1700+ if ( isSMSDomain ) {
1701+ return translateLocal ( 'workspace.new.myGroupWorkspace' , { workspaceNumber : lastWorkspaceNumber !== undefined ? lastWorkspaceNumber + 1 : undefined } ) ;
1702+ }
16991703 return translateLocal ( 'workspace.new.workspaceName' , { userName : displayNameForWorkspace , workspaceNumber : lastWorkspaceNumber !== undefined ? lastWorkspaceNumber + 1 : undefined } ) ;
17001704}
17011705
0 commit comments