Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve report preview action #20941

Merged
merged 7 commits into from
Jun 22, 2023
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
20 changes: 12 additions & 8 deletions src/pages/home/report/ReportActionItemSingle.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,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;
cristipaval marked this conversation as resolved.
Show resolved Hide resolved
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,
Expand All @@ -90,16 +93,17 @@ function ReportActionItemSingle(props) {
style={[styles.alignSelfStart, styles.mr3]}
onPressIn={ControlSelection.block}
onPressOut={ControlSelection.unblock}
disabled={isPolicyAction}
onPress={() => showUserDetails(actorAccountID)}
accessibilityLabel={actorEmail}
accessibilityLabel={isPolicyAction ? displayName : actorEmail}
cristipaval marked this conversation as resolved.
Show resolved Hide resolved
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: isPolicyAction ? CONST.ICON_TYPE_WORKSPACE : CONST.ICON_TYPE_AVATAR, name: displayName}}
secondaryAvatar={isPolicyAction ? {} : ReportUtils.getIcons(props.report, {})[props.report.isOwnPolicyExpenseChat ? 0 : 1]}
mainTooltip={isPolicyAction ? displayName : actorEmail}
secondaryTooltip={ReportUtils.getPolicyName(props.report)}
noMargin
/>
Expand All @@ -123,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) => (
Expand Down