Skip to content

Commit ccad061

Browse files
authored
Merge pull request #35027 from dukenv0307/fix/34052
Refactor task preview for hidden case
2 parents 17fdf50 + 03743f7 commit ccad061

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function MentionUserRenderer(props) {
6060
if (!_.isEmpty(htmlAttributeAccountID)) {
6161
const user = lodashGet(personalDetails, htmlAttributeAccountID);
6262
accountID = parseInt(htmlAttributeAccountID, 10);
63-
displayNameOrLogin = LocalePhoneNumber.formatPhoneNumber(lodashGet(user, 'login', '')) || lodashGet(user, 'displayName', '') || translate('common.hidden');
63+
displayNameOrLogin = lodashGet(user, 'displayName', '') || LocalePhoneNumber.formatPhoneNumber(lodashGet(user, 'login', '')) || translate('common.hidden');
6464
displayNameOrLogin = getMentionDisplayText(displayNameOrLogin, htmlAttributeAccountID, lodashGet(user, 'login', ''));
6565
navigationRoute = ROUTES.PROFILE.getRoute(htmlAttributeAccountID);
6666
} else if (!_.isEmpty(tnode.data)) {

src/components/ReportActionItem/TaskPreview.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import type {OnyxEntry} from 'react-native-onyx';
66
import Checkbox from '@components/Checkbox';
77
import Icon from '@components/Icon';
88
import * as Expensicons from '@components/Icon/Expensicons';
9-
import {usePersonalDetails} from '@components/OnyxProvider';
109
import PressableWithoutFeedback from '@components/Pressable/PressableWithoutFeedback';
1110
import RenderHTML from '@components/RenderHTML';
1211
import {showContextMenuForReport} from '@components/ShowContextMenuContext';
@@ -18,7 +17,6 @@ import useThemeStyles from '@hooks/useThemeStyles';
1817
import ControlSelection from '@libs/ControlSelection';
1918
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
2019
import getButtonState from '@libs/getButtonState';
21-
import * as LocalePhoneNumber from '@libs/LocalePhoneNumber';
2220
import Navigation from '@libs/Navigation/Navigation';
2321
import * as ReportUtils from '@libs/ReportUtils';
2422
import * as TaskUtils from '@libs/TaskUtils';
@@ -65,7 +63,6 @@ type TaskPreviewProps = WithCurrentUserPersonalDetailsProps &
6563
function TaskPreview({taskReport, taskReportID, action, contextMenuAnchor, chatReportID, checkIfContextMenuActive, currentUserPersonalDetails, isHovered = false}: TaskPreviewProps) {
6664
const styles = useThemeStyles();
6765
const StyleUtils = useStyleUtils();
68-
const personalDetails = usePersonalDetails() || CONST.EMPTY_OBJECT;
6966
const {translate} = useLocalize();
7067

7168
// The reportAction might not contain details regarding the taskReport
@@ -76,13 +73,8 @@ function TaskPreview({taskReport, taskReportID, action, contextMenuAnchor, chatR
7673
: action?.childStateNum === CONST.REPORT.STATE_NUM.APPROVED && action?.childStatusNum === CONST.REPORT.STATUS_NUM.APPROVED;
7774
const taskTitle = Str.htmlEncode(TaskUtils.getTaskTitle(taskReportID, action?.childReportName ?? ''));
7875
const taskAssigneeAccountID = Task.getTaskAssigneeAccountID(taskReport) ?? action?.childManagerAccountID ?? '';
79-
const assigneeLogin = personalDetails[taskAssigneeAccountID]?.login ?? '';
80-
const assigneeDisplayName = personalDetails[taskAssigneeAccountID]?.displayName ?? '';
81-
const taskAssignee = assigneeDisplayName || LocalePhoneNumber.formatPhoneNumber(assigneeLogin);
8276
const htmlForTaskPreview =
83-
taskAssignee && taskAssigneeAccountID !== 0
84-
? `<comment><mention-user accountid="${taskAssigneeAccountID}">@${taskAssignee}</mention-user> ${taskTitle}</comment>`
85-
: `<comment>${taskTitle}</comment>`;
77+
taskAssigneeAccountID !== 0 ? `<comment><mention-user accountid="${taskAssigneeAccountID}"></mention-user> ${taskTitle}</comment>` : `<comment>${taskTitle}</comment>`;
8678
const isDeletedParentAction = ReportUtils.isCanceledTaskReport(taskReport, action);
8779

8880
if (isDeletedParentAction) {

0 commit comments

Comments
 (0)