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
3 changes: 2 additions & 1 deletion src/libs/SidebarUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ 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) {
Expand Down
37 changes: 26 additions & 11 deletions src/pages/home/report/ReportActionItemSingle.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -66,11 +66,18 @@ const showUserDetails = (accountID) => {
Navigation.navigate(ROUTES.getProfileRoute(accountID));
};

const showWorkspaceDetails = (reportID) => {
Navigation.navigate(ROUTES.getReportDetailsRoute(reportID));
};

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 isWorkspaceActor = ReportUtils.isPolicyExpenseChat(props.report) && !actorAccountID;
const actorDetails = props.personalDetailsList[actorAccountID] || {};
const displayName = isWorkspaceActor ? ReportUtils.getPolicyName(props.report) : actorDetails.displayName;
const actorHint = isWorkspaceActor ? displayName : lodashGet(props.action, 'actorEmail', '').replace(CONST.REGEX.MERGED_ACCOUNT_PREFIX, '');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question @cristipaval : why are we only using displayName if isWorkspaceActor is true here? It looks like we set a displayName no matter what, so can't we just use that as an actorHint no matter what?

I'm working on removing actorEmail from everywhere since we should have actorAccountID everywhere that we have actorEmail - so I'm hoping we can just use displayName here always

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, displayName would be great. The thing is that this has also to be updated in Web-E as well, here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Groovy!

trueeeee our plan is to basically stop using it in App first, then stop sending from web-e 👍

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,
Expand All @@ -84,22 +91,30 @@ function ReportActionItemSingle(props) {
]
: props.action.person;

const showActorDetails = useCallback(() => {
if (isWorkspaceActor) {
showWorkspaceDetails(props.report.reportID);
} else {
showUserDetails(actorAccountID);
}
}, [isWorkspaceActor, props.report.reportID, actorAccountID]);

return (
<View style={props.wrapperStyles}>
<PressableWithoutFeedback
style={[styles.alignSelfStart, styles.mr3]}
onPressIn={ControlSelection.block}
onPressOut={ControlSelection.unblock}
onPress={() => showUserDetails(actorAccountID)}
accessibilityLabel={actorEmail}
onPress={showActorDetails}
accessibilityLabel={actorHint}
accessibilityRole="button"
>
<OfflineWithFeedback pendingAction={lodashGet(pendingFields, 'avatar', null)}>
{props.shouldShowSubscriptAvatar ? (
<SubscriptAvatar
mainAvatar={{source: avatarSource, type: CONST.ICON_TYPE_AVATAR}}
secondaryAvatar={ReportUtils.getIcons(props.report, {})[props.report.isOwnPolicyExpenseChat ? 0 : 1]}
mainTooltip={actorEmail}
mainAvatar={{source: avatarSource, type: isWorkspaceActor ? CONST.ICON_TYPE_WORKSPACE : CONST.ICON_TYPE_AVATAR, name: displayName}}
secondaryAvatar={isWorkspaceActor ? {} : ReportUtils.getIcons(props.report, {})[props.report.isOwnPolicyExpenseChat ? 0 : 1]}
mainTooltip={actorHint}
secondaryTooltip={ReportUtils.getPolicyName(props.report)}
noMargin
/>
Expand All @@ -122,8 +137,8 @@ function ReportActionItemSingle(props) {
style={[styles.flexShrink1, styles.mr1]}
onPressIn={ControlSelection.block}
onPressOut={ControlSelection.unblock}
onPress={() => showUserDetails(actorAccountID)}
accessibilityLabel={actorEmail}
onPress={showActorDetails}
accessibilityLabel={actorHint}
accessibilityRole="button"
>
{_.map(personArray, (fragment, index) => (
Expand Down