From 17c120c37a138a9ab18b4c393a60c892bda16f52 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 10 Oct 2025 14:17:52 +0700 Subject: [PATCH 1/3] fix: User's name is not displayed in mention --- .../HTMLRenderers/MentionUserRenderer.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx index 48edc09d7a396..55c1c8f4d2402 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx @@ -43,7 +43,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona if (!isEmpty(htmlAttribAccountID) && personalDetails?.[htmlAttribAccountID]) { const user = personalDetails[htmlAttribAccountID]; accountID = parseInt(htmlAttribAccountID, 10); - mentionDisplayText = formatPhoneNumber(user?.login ?? '') || getDisplayNameOrDefault(user); + mentionDisplayText = getDisplayNameOrDefault(user) || formatPhoneNumber(user?.login ?? ''); mentionDisplayText = getShortMentionIfFound(mentionDisplayText, htmlAttributeAccountID, currentUserPersonalDetails, user?.login ?? '') ?? ''; navigationRoute = ROUTES.PROFILE.getRoute(accountID, Navigation.getReportRHPActiveRoute()); } else if ('data' in tnode && !isEmptyObject(tnode.data)) { @@ -57,8 +57,14 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona ); accountID = getAccountIDsByLogins([mentionDisplayText])?.at(0) ?? -1; + if (accountID !== -1) { + const user = personalDetails?.[accountID]; + mentionDisplayText = getDisplayNameOrDefault(user) || formatPhoneNumber(user?.login ?? ''); + mentionDisplayText = getShortMentionIfFound(mentionDisplayText, htmlAttributeAccountID, currentUserPersonalDetails, user?.login ?? '') ?? ''; + } else { + mentionDisplayText = Str.removeSMSDomain(mentionDisplayText); + } navigationRoute = ROUTES.PROFILE.getRoute(accountID, Navigation.getReportRHPActiveRoute(), mentionDisplayText); - mentionDisplayText = Str.removeSMSDomain(mentionDisplayText); } else { // If neither an account ID or email is provided, don't render anything return null; @@ -114,7 +120,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona testID="mention-user" href={`/${navigationRoute}`} > - {htmlAttribAccountID ? `@${mentionDisplayText}` : } + {(accountID && accountID !== -1) ? `@${mentionDisplayText}` : } From 3b0ebfa3d80367668dd93465545cc2d48214bc7f Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 10 Oct 2025 14:49:16 +0700 Subject: [PATCH 2/3] fix prettier --- .../HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx index 55c1c8f4d2402..477e044869773 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx @@ -120,7 +120,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona testID="mention-user" href={`/${navigationRoute}`} > - {(accountID && accountID !== -1) ? `@${mentionDisplayText}` : } + {accountID && accountID !== -1 ? `@${mentionDisplayText}` : } From 957664e45dc2d0f8bc73f52440d49691ffaf6b14 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Fri, 17 Oct 2025 13:34:40 +0700 Subject: [PATCH 3/3] fix random email case --- .../HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx | 2 +- src/libs/PersonalDetailsUtils.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx index 477e044869773..a6130522957f5 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx @@ -56,7 +56,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona Str.removeSMSDomain(getShortMentionIfFound(mentionDisplayText, htmlAttributeAccountID, currentUserPersonalDetails) ?? ''), ); - accountID = getAccountIDsByLogins([mentionDisplayText])?.at(0) ?? -1; + accountID = getAccountIDsByLogins([mentionDisplayText], false)?.at(0) ?? -1; if (accountID !== -1) { const user = personalDetails?.[accountID]; mentionDisplayText = getDisplayNameOrDefault(user) || formatPhoneNumber(user?.login ?? ''); diff --git a/src/libs/PersonalDetailsUtils.ts b/src/libs/PersonalDetailsUtils.ts index 52360cc79d605..ad97c8d8c7a34 100644 --- a/src/libs/PersonalDetailsUtils.ts +++ b/src/libs/PersonalDetailsUtils.ts @@ -147,12 +147,12 @@ function getPersonalDetailByEmail(email: string): PersonalDetails | undefined { * @param logins Array of user logins * @returns Array of accountIDs according to passed logins */ -function getAccountIDsByLogins(logins: string[]): number[] { +function getAccountIDsByLogins(logins: string[], shouldGenerateAccountID = true): number[] { return logins.reduce((foundAccountIDs, login) => { const currentDetail = personalDetails.find((detail) => detail?.login === login?.toLowerCase()); if (!currentDetail) { // generate an account ID because in this case the detail is probably new, so we don't have a real accountID yet - foundAccountIDs.push(generateAccountID(login)); + foundAccountIDs.push(shouldGenerateAccountID ? generateAccountID(login) : -1); } else { foundAccountIDs.push(Number(currentDetail.accountID)); }