Skip to content

Commit ce06778

Browse files
committed
Update actions for actionableMentionWhisper
1 parent a68c983 commit ce06778

2 files changed

Lines changed: 19 additions & 6 deletions

File tree

src/pages/home/report/PureReportActionItem.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import {formatPhoneNumber} from '@libs/LocalePhoneNumber';
5555
import Navigation from '@libs/Navigation/Navigation';
5656
import Permissions from '@libs/Permissions';
5757
import {getDisplayNameOrDefault} from '@libs/PersonalDetailsUtils';
58-
import {getCleanedTagName} from '@libs/PolicyUtils';
58+
import {getCleanedTagName, isPolicyAdmin, isPolicyOwner} from '@libs/PolicyUtils';
5959
import {
6060
extractLinksFromMessageHtml,
6161
getAddedApprovalRuleMessage,
@@ -358,6 +358,9 @@ type PureReportActionItemProps = {
358358

359359
/** Whether to show border for MoneyRequestReportPreviewContent */
360360
shouldShowBorder?: boolean;
361+
362+
/** Current user's account id */
363+
currentUserAccountID?: number;
361364
};
362365

363366
// This is equivalent to returning a negative boolean in normal functions, but we can keep the element return type
@@ -421,6 +424,7 @@ function PureReportActionItem({
421424
userBillingFundID,
422425
policies,
423426
shouldShowBorder,
427+
currentUserAccountID,
424428
}: PureReportActionItemProps) {
425429
const actionSheetAwareScrollViewContext = useContext(ActionSheetAwareScrollView.ActionSheetAwareScrollViewContext);
426430
const {translate, datetimeToCalendarTime} = useLocalize();
@@ -811,13 +815,18 @@ function PureReportActionItem({
811815
];
812816
}
813817

814-
return [
815-
{
818+
const actionableMentionWhisperOptions = [];
819+
820+
if (isPolicyAdmin(policy) || isPolicyOwner(policy, currentUserAccountID)) {
821+
actionableMentionWhisperOptions.push({
816822
text: 'actionableMentionWhisperOptions.inviteToSubmitExpense',
817823
key: `${action.reportActionID}-actionableMentionWhisper-${CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.INVITE_TO_SUBMIT_EXPENSE}`,
818824
onPress: () => resolveActionableMentionWhisper(reportID, action, CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.INVITE_TO_SUBMIT_EXPENSE, policy),
819825
isMediumSized: true,
820-
},
826+
});
827+
}
828+
829+
actionableMentionWhisperOptions.push(
821830
{
822831
text: 'actionableMentionWhisperOptions.inviteToChat',
823832
key: `${action.reportActionID}-actionableMentionWhisper-${CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.INVITE}`,
@@ -830,19 +839,21 @@ function PureReportActionItem({
830839
onPress: () => resolveActionableMentionWhisper(reportID, action, CONST.REPORT.ACTIONABLE_MENTION_WHISPER_RESOLUTION.NOTHING, policy),
831840
isMediumSized: true,
832841
},
833-
];
842+
);
843+
return actionableMentionWhisperOptions;
834844
}, [
835845
action,
836846
userBillingFundID,
837847
isActionableWhisper,
848+
policy,
849+
currentUserAccountID,
838850
reportID,
839851
originalReportID,
840852
isBetaEnabled,
841853
createDraftTransactionAndNavigateToParticipantSelector,
842854
dismissTrackExpenseActionableWhisper,
843855
resolveActionableReportMentionWhisper,
844856
resolveActionableMentionWhisper,
845-
policy,
846857
]);
847858

848859
/**

src/pages/home/report/ReportActionItem.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ function ReportActionItem({allReports, action, report, transactions, shouldShowD
5050
const originalReportID = useMemo(() => getOriginalReportID(reportID, action), [reportID, action]);
5151
const originalReport = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${originalReportID}`];
5252
const isOriginalReportArchived = useReportIsArchived(originalReportID);
53+
const [currentUserAccountID] = useOnyx(ONYXKEYS.SESSION, {canBeMissing: false, selector: (session) => session?.accountID});
5354
const [draftMessage] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS_DRAFTS}${originalReportID}`, {
5455
canBeMissing: true,
5556
selector: (draftMessagesForReport) => {
@@ -90,6 +91,7 @@ function ReportActionItem({allReports, action, report, transactions, shouldShowD
9091
action={action}
9192
report={report}
9293
policy={policy}
94+
currentUserAccountID={currentUserAccountID}
9395
draftMessage={draftMessage}
9496
iouReport={iouReport}
9597
taskReport={taskReport}

0 commit comments

Comments
 (0)