Skip to content

Commit

Permalink
Merge pull request #51459 from bernhardoj/fix/51186-hidden-shows-brie…
Browse files Browse the repository at this point in the history
…fly-when-mention-unknown-user

Fix hidden shows briefly when mentioning unknown user
  • Loading branch information
MariaHCD authored Nov 26, 2024
2 parents 664f826 + f63804f commit 2d5479e
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import isEmpty from 'lodash/isEmpty';
import React from 'react';
import {StyleSheet} from 'react-native';
import type {TextStyle} from 'react-native';
import {useOnyx} from 'react-native-onyx';
import type {CustomRendererProps, TPhrasing, TText} from 'react-native-render-html';
import {TNodeChildrenRenderer} from 'react-native-render-html';
import {usePersonalDetails} from '@components/OnyxProvider';
import {ShowContextMenuContext, showContextMenuForReport} from '@components/ShowContextMenuContext';
import Text from '@components/Text';
import UserDetailsTooltip from '@components/UserDetailsTooltip';
Expand All @@ -20,6 +20,7 @@ import Navigation from '@libs/Navigation/Navigation';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
import * as ReportUtils from '@libs/ReportUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {Route} from '@src/ROUTES';
import asMutable from '@src/types/utils/asMutable';
Expand All @@ -31,7 +32,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const htmlAttribAccountID = tnode.attributes.accountid;
const personalDetails = usePersonalDetails() || CONST.EMPTY_OBJECT;
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);
const htmlAttributeAccountID = tnode.attributes.accountid;

let accountID: number;
Expand All @@ -56,7 +57,7 @@ function MentionUserRenderer({style, tnode, TDefaultRenderer, currentUserPersona
return displayText.split('@').at(0);
};

if (!isEmpty(htmlAttribAccountID)) {
if (!isEmpty(htmlAttribAccountID) && personalDetails?.[htmlAttribAccountID]) {
const user = personalDetails[htmlAttribAccountID];
accountID = parseInt(htmlAttribAccountID, 10);
mentionDisplayText = LocalePhoneNumber.formatPhoneNumber(user?.login ?? '') || PersonalDetailsUtils.getDisplayNameOrDefault(user);
Expand Down

0 comments on commit 2d5479e

Please sign in to comment.