Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/MentionUserRendererTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => ({
Expand Down Expand Up @@ -134,6 +137,7 @@ function buildTNode({accountID, data}: {accountID?: string; data?: string}): TTe
describe('MentionUserRenderer', () => {
beforeEach(() => {
mockPersonalDetails = {};
IntlStore.load(CONST.LOCALES.DEFAULT);
jest.clearAllMocks();
});

Expand Down Expand Up @@ -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'},
Expand Down
Loading