Skip to content

Commit

Permalink
Merge pull request #8778 from Expensify/marco-showLastMessageCloseAction
Browse files Browse the repository at this point in the history
show closed action message when a workspace member is removed
  • Loading branch information
tgolen authored Apr 26, 2022
2 parents 84d058f + b6fefbc commit ddccd92
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import CONST from '../CONST';
import * as ReportUtils from './reportUtils';
import * as Localize from './Localize';
import Permissions from './Permissions';
import * as CollectionUtils from './CollectionUtils';

/**
* OptionsListUtils is used to build a list options passed to the OptionsList component. Several different UI views can
Expand Down Expand Up @@ -76,6 +77,18 @@ Onyx.connect({
},
});

const lastReportActions = {};
Onyx.connect({
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
callback: (actions, key) => {
if (!key || !actions) {
return;
}
const reportID = CollectionUtils.extractCollectionItemID(key);
lastReportActions[reportID] = _.last(_.toArray(actions));
},
});

// We are initializing a default avatar here so that we use the same default color for each user we are inviting. This
// will update when the OptionsListUtils re-loads. But will stay the same color for the life of the JS session.
const defaultAvatarForUserToInvite = ReportUtils.getDefaultAvatar();
Expand Down Expand Up @@ -221,11 +234,19 @@ function createOption(logins, personalDetails, report, {
const lastMessageTextFromReport = ReportUtils.isReportMessageAttachment({text: lodashGet(report, 'lastMessageText', ''), html: lodashGet(report, 'lastMessageHtml', '')})
? `[${Localize.translateLocal('common.attachment')}]`
: Str.htmlDecode(lodashGet(report, 'lastMessageText', ''));
let lastMessageText = report && !isArchivedRoom && hasMultipleParticipants && lastActorDetails
let lastMessageText = report && hasMultipleParticipants && lastActorDetails
? `${lastActorDetails.displayName}: `
: '';
lastMessageText += report ? lastMessageTextFromReport : '';

if (isPolicyExpenseChat && isArchivedRoom) {
const archiveReason = lodashGet(lastReportActions[report.reportID], 'originalMessage.reason', CONST.REPORT.ARCHIVE_REASON.DEFAULT);
lastMessageText = Localize.translate(preferredLocale, `reportArchiveReasons.${archiveReason}`, {
displayName: lastActorDetails.displayName,
policyName: ReportUtils.getPolicyName(report, policies),
});
}

const tooltipText = ReportUtils.getReportParticipantsTitle(lodashGet(report, ['participants'], []));
const subtitle = ReportUtils.getChatRoomSubtitle(report, policies);
let text;
Expand Down Expand Up @@ -270,7 +291,7 @@ function createOption(logins, personalDetails, report, {
iouReportAmount: lodashGet(iouReport, 'total', 0),
isChatRoom,
isArchivedRoom,
shouldShowSubscript: isPolicyExpenseChat && !report.isOwnPolicyExpenseChat,
shouldShowSubscript: isPolicyExpenseChat && !report.isOwnPolicyExpenseChat && !isArchivedRoom,
isPolicyExpenseChat,
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/HeaderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const HeaderView = (props) => {
// these users via alternative means. It is possible to request a call with Concierge so we leave the option for them.
const shouldShowCallButton = isConcierge || !isAutomatedExpensifyAccount;
const avatarTooltip = isChatRoom ? undefined : _.pluck(displayNamesWithTooltips, 'tooltip');
const shouldShowSubscript = isPolicyExpenseChat && !props.report.isOwnPolicyExpenseChat;
const shouldShowSubscript = isPolicyExpenseChat && !props.report.isOwnPolicyExpenseChat && !ReportUtils.isArchivedRoom(props.report);
const icons = ReportUtils.getIcons(props.report, props.personalDetails, props.policies);
return (
<View style={[styles.appContentHeader]} nativeID="drag-area">
Expand Down

0 comments on commit ddccd92

Please sign in to comment.