From 735676a508686aacdae78e8def84f87edfb80a89 Mon Sep 17 00:00:00 2001 From: apeyada Date: Tue, 13 Jan 2026 09:55:26 +0100 Subject: [PATCH 1/2] fix Account - Whisper message does not mention the teacher after referred --- .../HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx index 46943dff4b26d..b416132f09a3f 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx @@ -39,8 +39,8 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona let navigationRoute: Route; let tnodeClone: typeof tnode | undefined; - if (!isEmpty(htmlAttribAccountID) && personalDetails?.[htmlAttribAccountID]) { - const user = personalDetails[htmlAttribAccountID]; + if (!isEmpty(htmlAttribAccountID)) { + const user = personalDetails?.[htmlAttribAccountID]; accountID = parseInt(htmlAttribAccountID, 10); mentionDisplayText = formatPhoneNumber(user?.login ?? '') || getDisplayNameOrDefault(user); mentionDisplayText = getShortMentionIfFound(mentionDisplayText, htmlAttributeAccountID, currentUserPersonalDetails, user?.login ?? '') ?? ''; From 0b31baf5b59f9aa41140db20b074ed76a1b924d2 Mon Sep 17 00:00:00 2001 From: apeyada Date: Tue, 13 Jan 2026 10:47:40 +0100 Subject: [PATCH 2/2] add unit test --- .../HTMLRenderers/MentionUserRenderer.tsx | 9 +++++++-- tests/unit/MentionUserRendererTest.tsx | 11 +++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx index b416132f09a3f..fac38983df185 100644 --- a/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx +++ b/src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx @@ -39,8 +39,8 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona let navigationRoute: Route; let tnodeClone: typeof tnode | undefined; - if (!isEmpty(htmlAttribAccountID)) { - const user = personalDetails?.[htmlAttribAccountID]; + if (!isEmpty(htmlAttribAccountID) && personalDetails?.[htmlAttribAccountID]) { + const user = personalDetails[htmlAttribAccountID]; accountID = parseInt(htmlAttribAccountID, 10); mentionDisplayText = formatPhoneNumber(user?.login ?? '') || getDisplayNameOrDefault(user); mentionDisplayText = getShortMentionIfFound(mentionDisplayText, htmlAttributeAccountID, currentUserPersonalDetails, user?.login ?? '') ?? ''; @@ -58,6 +58,11 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona accountID = getAccountIDsByLogins([mentionDisplayText])?.at(0) ?? -1; navigationRoute = ROUTES.PROFILE.getRoute(accountID, Navigation.getReportRHPActiveRoute(), mentionDisplayText); mentionDisplayText = Str.removeSMSDomain(mentionDisplayText); + } else if (!isEmpty(htmlAttribAccountID)) { + // accountID not found in personal details and mention data not provided + accountID = parseInt(htmlAttribAccountID, 10); + mentionDisplayText = getDisplayNameOrDefault(); + navigationRoute = ROUTES.PROFILE.getRoute(accountID, Navigation.getReportRHPActiveRoute()); } else { // If neither an account ID or email is provided, don't render anything return null; diff --git a/tests/unit/MentionUserRendererTest.tsx b/tests/unit/MentionUserRendererTest.tsx index f0052ecd0f360..e134777bbf855 100644 --- a/tests/unit/MentionUserRendererTest.tsx +++ b/tests/unit/MentionUserRendererTest.tsx @@ -8,8 +8,11 @@ import OnyxListItemProvider from '@components/OnyxListItemProvider'; import {ShowContextMenuContext} from '@components/ShowContextMenuContext'; import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails'; import Navigation from '@libs/Navigation/Navigation'; +import CONST from '@src/CONST'; +import IntlStore from '@src/languages/IntlStore'; import ROUTES from '@src/ROUTES'; import type {PersonalDetails} from '@src/types/onyx'; +import {translateLocal} from '../utils/TestHelper'; // Mock Navigation to avoid actual navigation calls jest.mock('@libs/Navigation/Navigation', () => ({ @@ -134,6 +137,7 @@ function buildTNode({accountID, data}: {accountID?: string; data?: string}): TTe describe('MentionUserRenderer', () => { beforeEach(() => { mockPersonalDetails = {}; + IntlStore.load(CONST.LOCALES.DEFAULT); jest.clearAllMocks(); }); @@ -188,6 +192,13 @@ describe('MentionUserRenderer', () => { expect(toJSON()).toBeNull(); }); + test('renders @Hidden when accountID not found in personal details and mention data not provided', () => { + mockPersonalDetails = {}; + const tnode = buildTNode({accountID: '203'}); + renderMention({tnode}); + expect(screen.getByText(`@${translateLocal('common.hidden')}`)).toBeVisible(); + }); + test('navigates to user profile when pressed with accountID', () => { mockPersonalDetails = { 103: {login: 'john@example.com', displayName: 'John Doe'},