@@ -35,12 +35,12 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
35
35
const htmlAttributeAccountID = tnode . attributes . accountid ;
36
36
37
37
let accountID : number ;
38
- let displayNameOrLogin : string ;
38
+ let mentionDisplayText : string ;
39
39
let navigationRoute : Route ;
40
40
41
41
const tnodeClone = cloneDeep ( tnode ) ;
42
42
43
- const getMentionDisplayText = ( displayText : string , userAccountID : string , userLogin = '' ) => {
43
+ const getShortMentionIfFound = ( displayText : string , userAccountID : string , userLogin = '' ) => {
44
44
// If the userAccountID does not exist, this is an email-based mention so the displayText must be an email.
45
45
// If the userAccountID exists but userLogin is different from displayText, this means the displayText is either user display name, Hidden, or phone number, in which case we should return it as is.
46
46
if ( userAccountID && userLogin !== displayText ) {
@@ -59,18 +59,18 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
59
59
if ( ! isEmpty ( htmlAttribAccountID ) ) {
60
60
const user = personalDetails [ htmlAttribAccountID ] ;
61
61
accountID = parseInt ( htmlAttribAccountID , 10 ) ;
62
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
63
- displayNameOrLogin = PersonalDetailsUtils . getDisplayNameOrDefault ( user , LocalePhoneNumber . formatPhoneNumber ( user ?. login ?? '' ) ) ;
62
+ mentionDisplayText = LocalePhoneNumber . formatPhoneNumber ( user ?. login ?? '' ) || PersonalDetailsUtils . getDisplayNameOrDefault ( user ) ;
63
+ mentionDisplayText = getShortMentionIfFound ( mentionDisplayText , htmlAttributeAccountID , user ?. login ?? '' ) ;
64
64
navigationRoute = ROUTES . PROFILE . getRoute ( htmlAttribAccountID ) ;
65
65
} else if ( 'data' in tnodeClone && ! isEmptyObject ( tnodeClone . data ) ) {
66
66
// We need to remove the LTR unicode and leading @ from data as it is not part of the login
67
- displayNameOrLogin = tnodeClone . data . replace ( CONST . UNICODE . LTR , '' ) . slice ( 1 ) ;
67
+ mentionDisplayText = tnodeClone . data . replace ( CONST . UNICODE . LTR , '' ) . slice ( 1 ) ;
68
68
// We need to replace tnode.data here because we will pass it to TNodeChildrenRenderer below
69
- asMutable ( tnodeClone ) . data = tnodeClone . data . replace ( displayNameOrLogin , Str . removeSMSDomain ( getMentionDisplayText ( displayNameOrLogin , htmlAttributeAccountID ) ) ) ;
69
+ asMutable ( tnodeClone ) . data = tnodeClone . data . replace ( mentionDisplayText , Str . removeSMSDomain ( getShortMentionIfFound ( mentionDisplayText , htmlAttributeAccountID ) ) ) ;
70
70
71
- accountID = PersonalDetailsUtils . getAccountIDsByLogins ( [ displayNameOrLogin ] ) ?. [ 0 ] ;
72
- navigationRoute = ROUTES . DETAILS . getRoute ( displayNameOrLogin ) ;
73
- displayNameOrLogin = Str . removeSMSDomain ( displayNameOrLogin ) ;
71
+ accountID = PersonalDetailsUtils . getAccountIDsByLogins ( [ mentionDisplayText ] ) ?. [ 0 ] ;
72
+ navigationRoute = ROUTES . DETAILS . getRoute ( mentionDisplayText ) ;
73
+ mentionDisplayText = Str . removeSMSDomain ( mentionDisplayText ) ;
74
74
} else {
75
75
// If neither an account ID or email is provided, don't render anything
76
76
return null ;
@@ -97,7 +97,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
97
97
< UserDetailsTooltip
98
98
accountID = { accountID }
99
99
fallbackUserDetails = { {
100
- displayName : displayNameOrLogin ,
100
+ displayName : mentionDisplayText ,
101
101
} }
102
102
>
103
103
< Text
@@ -108,7 +108,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
108
108
testID = "span"
109
109
href = { `/${ navigationRoute } ` }
110
110
>
111
- { htmlAttribAccountID ? `@${ displayNameOrLogin } ` : < TNodeChildrenRenderer tnode = { tnodeClone } /> }
111
+ { htmlAttribAccountID ? `@${ mentionDisplayText } ` : < TNodeChildrenRenderer tnode = { tnodeClone } /> }
112
112
</ Text >
113
113
</ UserDetailsTooltip >
114
114
</ Text >
0 commit comments