@@ -13,6 +13,7 @@ import {clearDelegatorErrors, connect, disconnect} from '@libs/actions/Delegate'
1313import { close } from '@libs/actions/Modal' ;
1414import { getLatestError } from '@libs/ErrorUtils' ;
1515import { getPersonalDetailByEmail } from '@libs/PersonalDetailsUtils' ;
16+ import TextWithEmojiFragment from '@pages/home/report/comment/TextWithEmojiFragment' ;
1617import variables from '@styles/variables' ;
1718import CONST from '@src/CONST' ;
1819import ONYXKEYS from '@src/ONYXKEYS' ;
@@ -53,6 +54,8 @@ function AccountSwitcher({isScreenFocused}: AccountSwitcherProps) {
5354
5455 const isActingAsDelegate = ! ! account ?. delegatedAccess ?. delegate ;
5556 const canSwitchAccounts = delegators . length > 0 || isActingAsDelegate ;
57+ const displayName = currentUserPersonalDetails ?. displayName ?? '' ;
58+ const doesDisplayNameContainEmojis = new RegExp ( CONST . REGEX . EMOJIS , CONST . REGEX . EMOJIS . flags . concat ( 'g' ) ) . test ( displayName ) ;
5659
5760 const { shouldShowProductTrainingTooltip, renderProductTrainingTooltip, hideProductTrainingTooltip} = useProductTrainingContext (
5861 CONST . PRODUCT_TRAINING_TOOLTIP_NAMES . ACCOUNT_SWITCHER ,
@@ -189,12 +192,21 @@ function AccountSwitcher({isScreenFocused}: AccountSwitcherProps) {
189192 />
190193 < View style = { [ styles . flex1 , styles . flexShrink1 , styles . flexBasis0 , styles . justifyContentCenter , styles . gap1 ] } >
191194 < View style = { [ styles . flexRow , styles . gap1 ] } >
192- < Text
193- numberOfLines = { 1 }
194- style = { [ styles . textBold , styles . textLarge , styles . flexShrink1 , styles . lineHeightXLarge ] }
195- >
196- { currentUserPersonalDetails ?. displayName }
197- </ Text >
195+ { doesDisplayNameContainEmojis ? (
196+ < Text numberOfLines = { 1 } >
197+ < TextWithEmojiFragment
198+ message = { displayName }
199+ style = { [ styles . textBold , styles . textLarge , styles . flexShrink1 , styles . lineHeightXLarge ] }
200+ />
201+ </ Text >
202+ ) : (
203+ < Text
204+ numberOfLines = { 1 }
205+ style = { [ styles . textBold , styles . textLarge , styles . flexShrink1 , styles . lineHeightXLarge ] }
206+ >
207+ { displayName }
208+ </ Text >
209+ ) }
198210 { ! ! canSwitchAccounts && (
199211 < View style = { styles . justifyContentCenter } >
200212 < Icon
0 commit comments