Skip to content

Commit be08a6b

Browse files
committed
remove report prop from SimpleMessageContent
1 parent 37da594 commit be08a6b

3 files changed

Lines changed: 27 additions & 17 deletions

File tree

src/pages/inbox/report/actionContents/ActionContentRouter.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import MentionWhisperContent from './MentionWhisperContent';
5757
import ModifiedExpenseContent from './ModifiedExpenseContent';
5858
import PaymentContent from './PaymentContent';
5959
import PolicyChangeLogContent, {isHandledPolicyChangeLogAction} from './PolicyChangeLogContent';
60+
import ReceiptScanFailedContent from './ReceiptScanFailedContent';
6061
import ReimbursedContent from './ReimbursedContent';
6162
import ReimbursementDeQueuedContent from './ReimbursementDeQueuedContent';
6263
import ReimbursementQueuedContent from './ReimbursementQueuedContent';
@@ -286,14 +287,17 @@ function ActionContentRouter({
286287
/>
287288
);
288289
}
289-
if (isSimpleMessageAction(action)) {
290+
if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.RECEIPT_SCAN_FAILED)) {
290291
return (
291-
<SimpleMessageContent
292-
action={action}
293-
report={report}
292+
<ReceiptScanFailedContent
293+
parentReportID={report?.parentReportID}
294+
parentReportActionID={report?.parentReportActionID}
294295
/>
295296
);
296297
}
298+
if (isSimpleMessageAction(action)) {
299+
return <SimpleMessageContent action={action} />;
300+
}
297301
if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.FORWARDED)) {
298302
const wasAutoForwarded = getOriginalMessage(action)?.automaticAction ?? false;
299303
if (wasAutoForwarded) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
import useLocalize from '@hooks/useLocalize';
3+
import {getReportAction, wasActionTakenByCurrentUser} from '@libs/ReportActionsUtils';
4+
import ReportActionItemBasicMessage from '@pages/inbox/report/ReportActionItemBasicMessage';
5+
6+
type ReceiptScanFailedContentProps = {
7+
parentReportID: string | undefined;
8+
parentReportActionID: string | undefined;
9+
};
10+
11+
// RECEIPT_SCAN_FAILED is submitted by Concierge, so use the parent IOU action to determine edit permission.
12+
function ReceiptScanFailedContent({parentReportID, parentReportActionID}: ReceiptScanFailedContentProps) {
13+
const {translate} = useLocalize();
14+
const iouAction = getReportAction(parentReportID, parentReportActionID);
15+
return <ReportActionItemBasicMessage message={translate('violations.smartscanFailed', {canEdit: wasActionTakenByCurrentUser(iouAction)})} />;
16+
}
17+
18+
export default ReceiptScanFailedContent;

src/pages/inbox/report/actionContents/SimpleMessageContent.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import type {OnyxEntry} from 'react-native-onyx';
32
import useLocalize from '@hooks/useLocalize';
43
import {
54
getActionableCard3DSTransactionApprovalMessage,
@@ -9,12 +8,10 @@ import {
98
getMessageOfOldDotReportAction,
109
getOriginalMessage,
1110
getRemovedFromApprovalChainMessage,
12-
getReportAction,
1311
getReportActionText,
1412
isActionOfType,
1513
isRejectedAction,
1614
isUnapprovedAction,
17-
wasActionTakenByCurrentUser,
1815
} from '@libs/ReportActionsUtils';
1916
import {getDeletedTransactionMessage, getPolicyChangeMessage} from '@libs/ReportUtils';
2017
import ReportActionItemBasicMessage from '@pages/inbox/report/ReportActionItemBasicMessage';
@@ -23,7 +20,6 @@ import type * as OnyxTypes from '@src/types/onyx';
2320

2421
type SimpleMessageContentProps = {
2522
action: OnyxTypes.ReportAction;
26-
report: OnyxEntry<OnyxTypes.Report>;
2723
};
2824

2925
const SIMPLE_MESSAGE_ACTION_TYPES = new Set<string>([
@@ -40,7 +36,6 @@ const SIMPLE_MESSAGE_ACTION_TYPES = new Set<string>([
4036
CONST.REPORT.ACTIONS.TYPE.MERGED_WITH_CASH_TRANSACTION,
4137
CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION,
4238
CONST.REPORT.ACTIONS.TYPE.RESOLVED_DUPLICATES,
43-
CONST.REPORT.ACTIONS.TYPE.RECEIPT_SCAN_FAILED,
4439
CONST.REPORT.ACTIONS.TYPE.DEMOTED_FROM_WORKSPACE,
4540
CONST.REPORT.ACTIONS.TYPE.ACTIONABLE_CARD_3DS_TRANSACTION_APPROVAL,
4641
CONST.REPORT.ACTIONS.TYPE.REMOVED_FROM_APPROVAL_CHAIN,
@@ -51,7 +46,7 @@ function isSimpleMessageAction(action: OnyxTypes.ReportAction): boolean {
5146
return SIMPLE_MESSAGE_ACTION_TYPES.has(action.actionName) || isUnapprovedAction(action) || isRejectedAction(action);
5247
}
5348

54-
function SimpleMessageContent({action, report}: SimpleMessageContentProps) {
49+
function SimpleMessageContent({action}: SimpleMessageContentProps) {
5550
const {translate} = useLocalize();
5651

5752
if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.MARKED_REIMBURSED)) {
@@ -93,11 +88,6 @@ function SimpleMessageContent({action, report}: SimpleMessageContentProps) {
9388
if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.RESOLVED_DUPLICATES)) {
9489
return <ReportActionItemBasicMessage message={translate('violations.resolvedDuplicates')} />;
9590
}
96-
if (isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.RECEIPT_SCAN_FAILED)) {
97-
// RECEIPT_SCAN_FAILED is submitted by Concierge, so use the IOU action to determine edit permission
98-
const iouAction = getReportAction(report?.parentReportID, report?.parentReportActionID);
99-
return <ReportActionItemBasicMessage message={translate('violations.smartscanFailed', {canEdit: wasActionTakenByCurrentUser(iouAction)})} />;
100-
}
10191
if (isUnapprovedAction(action)) {
10292
return <ReportActionItemBasicMessage message={translate('iou.unapproved')} />;
10393
}
@@ -120,7 +110,5 @@ function SimpleMessageContent({action, report}: SimpleMessageContentProps) {
120110
return null;
121111
}
122112

123-
SimpleMessageContent.displayName = 'SimpleMessageContent';
124-
125113
export default SimpleMessageContent;
126114
export {isSimpleMessageAction};

0 commit comments

Comments
 (0)