From fc21c08b6b17ab09b710c4d7337f5c3a364a3994 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Fri, 16 Jun 2023 23:35:17 +0300 Subject: [PATCH 1/6] Show workspace avatar and name for report preview action when workspace owes money --- src/pages/home/report/ReportActionItemSingle.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/pages/home/report/ReportActionItemSingle.js b/src/pages/home/report/ReportActionItemSingle.js index fa299858c338..110c01805301 100644 --- a/src/pages/home/report/ReportActionItemSingle.js +++ b/src/pages/home/report/ReportActionItemSingle.js @@ -66,10 +66,13 @@ const showUserDetails = (accountID) => { }; function ReportActionItemSingle(props) { - const actorEmail = lodashGet(props.action, 'actorEmail', '').replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, ''); const actorAccountID = props.action.actorAccountID; - const {avatar, displayName, pendingFields} = props.personalDetailsList[actorAccountID] || {}; - const avatarSource = UserUtils.getAvatar(avatar, actorAccountID); + const isPolicyAction = ReportUtils.isPolicyExpenseChat(props.report) && !actorAccountID; + const actorEmail = lodashGet(props.action, 'actorEmail', '').replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, ''); + const actorDetails = props.personalDetailsList[actorAccountID] || {}; + const displayName = isPolicyAction ? ReportUtils.getPolicyName(props.report) : actorDetails.displayName; + const pendingFields = isPolicyAction ? {} : actorDetails.pendingFields; + const avatarSource = isPolicyAction ? ReportUtils.getWorkspaceAvatar(props.report) : UserUtils.getAvatar(actorDetails.avatar, actorAccountID); // Since the display name for a report action message is delivered with the report history as an array of fragments // we'll need to take the displayName from personal details and have it be in the same format for now. Eventually, @@ -89,13 +92,14 @@ function ReportActionItemSingle(props) { style={[styles.alignSelfStart, styles.mr3]} onPressIn={ControlSelection.block} onPressOut={ControlSelection.unblock} + disabled={isPolicyAction} onPress={() => showUserDetails(actorAccountID)} > {props.shouldShowSubscriptAvatar ? ( Date: Wed, 21 Jun 2023 16:37:35 +0300 Subject: [PATCH 2/6] don't show the actor name in sidebar when last report action actor is the workspace --- src/libs/SidebarUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/SidebarUtils.js b/src/libs/SidebarUtils.js index a41249ebfa3d..5c3ec26e56a2 100644 --- a/src/libs/SidebarUtils.js +++ b/src/libs/SidebarUtils.js @@ -313,7 +313,7 @@ function getOptionData(reportID) { } : null; } - let lastMessageText = hasMultipleParticipants && lastActorDetails && Number(lastActorDetails.accountID) !== currentUserAccountID ? `${lastActorDetails.displayName}: ` : ''; + let lastMessageText = hasMultipleParticipants && lastActorDetails && lastActorDetails.accountID && Number(lastActorDetails.accountID) !== currentUserAccountID ? `${lastActorDetails.displayName}: ` : ''; lastMessageText += report ? lastMessageTextFromReport : ''; if (result.isArchivedRoom) { From f01a341a3bb0f2f982b5e5facc8e64d4911a65b2 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Wed, 21 Jun 2023 16:56:13 +0300 Subject: [PATCH 3/6] Fix tooltip text for report actions where the actor is the workspace --- src/pages/home/report/ReportActionItemSingle.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/home/report/ReportActionItemSingle.js b/src/pages/home/report/ReportActionItemSingle.js index e31b91289ac0..34f52468cddd 100644 --- a/src/pages/home/report/ReportActionItemSingle.js +++ b/src/pages/home/report/ReportActionItemSingle.js @@ -95,7 +95,7 @@ function ReportActionItemSingle(props) { onPressOut={ControlSelection.unblock} disabled={isPolicyAction} onPress={() => showUserDetails(actorAccountID)} - accessibilityLabel={actorEmail} + accessibilityLabel={isPolicyAction ? displayName : actorEmail} accessibilityRole="button" > @@ -103,7 +103,7 @@ function ReportActionItemSingle(props) { @@ -127,7 +127,7 @@ function ReportActionItemSingle(props) { onPressIn={ControlSelection.block} onPressOut={ControlSelection.unblock} onPress={() => showUserDetails(actorAccountID)} - accessibilityLabel={actorEmail} + accessibilityLabel={isPolicyAction ? displayName : actorEmail} accessibilityRole="button" > {_.map(personArray, (fragment, index) => ( From fd484712096c810d05a02f89fd28867ffa783ef4 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Wed, 21 Jun 2023 17:32:16 +0300 Subject: [PATCH 4/6] Run prettier --- src/libs/SidebarUtils.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/SidebarUtils.js b/src/libs/SidebarUtils.js index 5c3ec26e56a2..3c2639a75652 100644 --- a/src/libs/SidebarUtils.js +++ b/src/libs/SidebarUtils.js @@ -313,7 +313,8 @@ function getOptionData(reportID) { } : null; } - let lastMessageText = hasMultipleParticipants && lastActorDetails && lastActorDetails.accountID && Number(lastActorDetails.accountID) !== currentUserAccountID ? `${lastActorDetails.displayName}: ` : ''; + let lastMessageText = + hasMultipleParticipants && lastActorDetails && lastActorDetails.accountID && Number(lastActorDetails.accountID) !== currentUserAccountID ? `${lastActorDetails.displayName}: ` : ''; lastMessageText += report ? lastMessageTextFromReport : ''; if (result.isArchivedRoom) { From 4e0fdcc2bf7c93bd33896d36675cf88076e3d7dd Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Wed, 21 Jun 2023 21:44:56 +0300 Subject: [PATCH 5/6] Address feedback after review. --- .../home/report/ReportActionItemSingle.js | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/pages/home/report/ReportActionItemSingle.js b/src/pages/home/report/ReportActionItemSingle.js index 34f52468cddd..d96d6c4c1890 100644 --- a/src/pages/home/report/ReportActionItemSingle.js +++ b/src/pages/home/report/ReportActionItemSingle.js @@ -68,12 +68,12 @@ const showUserDetails = (accountID) => { function ReportActionItemSingle(props) { const actorAccountID = props.action.actorAccountID; - const isPolicyAction = ReportUtils.isPolicyExpenseChat(props.report) && !actorAccountID; - const actorEmail = lodashGet(props.action, 'actorEmail', '').replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, ''); + const isWorkspaceActor = ReportUtils.isPolicyExpenseChat(props.report) && !actorAccountID; const actorDetails = props.personalDetailsList[actorAccountID] || {}; - const displayName = isPolicyAction ? ReportUtils.getPolicyName(props.report) : actorDetails.displayName; - const pendingFields = isPolicyAction ? {} : actorDetails.pendingFields; - const avatarSource = isPolicyAction ? ReportUtils.getWorkspaceAvatar(props.report) : UserUtils.getAvatar(actorDetails.avatar, actorAccountID); + const displayName = isWorkspaceActor ? ReportUtils.getPolicyName(props.report) : actorDetails.displayName; + const actorHint = isWorkspaceActor ? displayName : lodashGet(props.action, 'actorEmail', '').replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, ''); + const pendingFields = isWorkspaceActor ? {} : actorDetails.pendingFields; + const avatarSource = isWorkspaceActor ? ReportUtils.getWorkspaceAvatar(props.report) : UserUtils.getAvatar(actorDetails.avatar, actorAccountID); // Since the display name for a report action message is delivered with the report history as an array of fragments // we'll need to take the displayName from personal details and have it be in the same format for now. Eventually, @@ -93,17 +93,17 @@ function ReportActionItemSingle(props) { style={[styles.alignSelfStart, styles.mr3]} onPressIn={ControlSelection.block} onPressOut={ControlSelection.unblock} - disabled={isPolicyAction} + disabled={isWorkspaceActor} onPress={() => showUserDetails(actorAccountID)} - accessibilityLabel={isPolicyAction ? displayName : actorEmail} + accessibilityLabel={actorHint} accessibilityRole="button" > {props.shouldShowSubscriptAvatar ? ( @@ -127,7 +127,7 @@ function ReportActionItemSingle(props) { onPressIn={ControlSelection.block} onPressOut={ControlSelection.unblock} onPress={() => showUserDetails(actorAccountID)} - accessibilityLabel={isPolicyAction ? displayName : actorEmail} + accessibilityLabel={actorHint} accessibilityRole="button" > {_.map(personArray, (fragment, index) => ( From 46bf1b9b5eeb1e155844ec963644eca432c3ba19 Mon Sep 17 00:00:00 2001 From: Cristi Paval Date: Thu, 22 Jun 2023 00:32:18 +0300 Subject: [PATCH 6/6] Fix click handler on avatar and display name for report previews in workspace chats --- .../home/report/ReportActionItemSingle.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/pages/home/report/ReportActionItemSingle.js b/src/pages/home/report/ReportActionItemSingle.js index d96d6c4c1890..59307bd66734 100644 --- a/src/pages/home/report/ReportActionItemSingle.js +++ b/src/pages/home/report/ReportActionItemSingle.js @@ -1,5 +1,5 @@ import lodashGet from 'lodash/get'; -import React from 'react'; +import React, {useCallback} from 'react'; import {View} from 'react-native'; import PropTypes from 'prop-types'; import _ from 'underscore'; @@ -66,6 +66,10 @@ const showUserDetails = (accountID) => { Navigation.navigate(ROUTES.getProfileRoute(accountID)); }; +const showWorkspaceDetails = (reportID) => { + Navigation.navigate(ROUTES.getReportDetailsRoute(reportID)); +}; + function ReportActionItemSingle(props) { const actorAccountID = props.action.actorAccountID; const isWorkspaceActor = ReportUtils.isPolicyExpenseChat(props.report) && !actorAccountID; @@ -87,14 +91,21 @@ function ReportActionItemSingle(props) { ] : props.action.person; + const showActorDetails = useCallback(() => { + if (isWorkspaceActor) { + showWorkspaceDetails(props.report.reportID); + } else { + showUserDetails(actorAccountID); + } + }, [isWorkspaceActor, props.report.reportID, actorAccountID]); + return ( showUserDetails(actorAccountID)} + onPress={showActorDetails} accessibilityLabel={actorHint} accessibilityRole="button" > @@ -126,7 +137,7 @@ function ReportActionItemSingle(props) { style={[styles.flexShrink1, styles.mr1]} onPressIn={ControlSelection.block} onPressOut={ControlSelection.unblock} - onPress={() => showUserDetails(actorAccountID)} + onPress={showActorDetails} accessibilityLabel={actorHint} accessibilityRole="button" >