From 95e03f4af6e3abed1077f133027dc862348ca7bf Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Thu, 25 Apr 2024 18:40:52 -0700 Subject: [PATCH 1/7] Add support for DISMISSED_VIOLATION system message --- src/CONST.ts | 1 + src/languages/en.ts | 5 +++++ src/languages/es.ts | 5 +++++ src/libs/ReportActionsUtils.ts | 7 +++++++ src/pages/home/report/ReportActionItem.tsx | 3 +++ 5 files changed, 21 insertions(+) diff --git a/src/CONST.ts b/src/CONST.ts index a85d024b19f7..35a40276e0a0 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -650,6 +650,7 @@ const CONST = { CREATED: 'CREATED', DELEGATE_SUBMIT: 'DELEGATESUBMIT', // OldDot Action DELETED_ACCOUNT: 'DELETEDACCOUNT', // OldDot Action + DISMISSED_VIOLATION: 'DISMISSEDVIOLATION', DONATION: 'DONATION', // OldDot Action EXPORTED_TO_CSV: 'EXPORTEDTOCSV', // OldDot Action EXPORTED_TO_INTEGRATION: 'EXPORTEDTOINTEGRATION', // OldDot Action diff --git a/src/languages/en.ts b/src/languages/en.ts index e00325837af2..797792c598eb 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2807,6 +2807,11 @@ export default { taxRateChanged: 'Tax rate was modified', taxRequired: 'Missing tax rate', }, + violationDismissal: { + rter:{ + manual: 'marked this receipt as cash, confirming it doesn\'t match a credit card transaction', + } + }, videoPlayer: { play: 'Play', pause: 'Pause', diff --git a/src/languages/es.ts b/src/languages/es.ts index 5011793b3295..511dbd16e078 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -3303,6 +3303,11 @@ export default { taxRateChanged: 'La tasa de impuesto fue modificada', taxRequired: 'Falta la tasa de impuesto', }, + violationDismissal: { + rter:{ + manual: 'marcó este recibo como efectivo, confirmando que no coincide con una transacción de tarjeta de crédito', + } + }, videoPlayer: { play: 'Reproducir', pause: 'Pausar', diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 97b2b62391c4..63e5acb80b6b 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1106,8 +1106,15 @@ function getReportActionMessageText(reportAction: OnyxEntry | Empt return reportAction?.message?.reduce((acc, curr) => `${acc}${curr?.text}`, '') ?? ''; } +function getDismissedViolationMessageText(originalMessage): string { + const reason = originalMessage.reason; + const violationName = originalMessage.violationName; + return Localize.translateLocal(`violationDismissal.${violationName}.${reason}`); +} + export { extractLinksFromMessageHtml, + getDismissedViolationMessageText, getOneTransactionThreadReportID, getIOUReportIDFromReportActionPreview, getLastClosedReportAction, diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index c07b693001e0..d9b3a107f27c 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -79,6 +79,7 @@ import ReportActionItemMessageEdit from './ReportActionItemMessageEdit'; import ReportActionItemSingle from './ReportActionItemSingle'; import ReportActionItemThread from './ReportActionItemThread'; import ReportAttachmentsContext from './ReportAttachmentsContext'; +import {getDismissedViolationMessageText} from "@libs/ReportActionsUtils"; const getDraftMessage = (drafts: OnyxCollection, reportID: string, action: OnyxTypes.ReportAction): string | undefined => { const originalReportID = ReportUtils.getOriginalReportID(reportID, action); @@ -586,6 +587,8 @@ function ReportActionItem({ children = ; } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) { children = ; + } else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION) { + children = ; } else { const hasBeenFlagged = ![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === moderationDecision) && From 93059447c2dd6b91bf9d85824501c73d184b9989 Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Mon, 29 Apr 2024 18:13:28 -0700 Subject: [PATCH 2/7] Fi types for dimissed violation system message --- src/libs/ReportActionsUtils.ts | 6 ++++-- src/types/onyx/OriginalMessage.ts | 12 +++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index ed0fd543ac50..1de5b8f57b80 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -14,6 +14,7 @@ import type { OriginalMessageIOU, OriginalMessageJoinPolicyChangeLog, OriginalMessageReimbursementDequeued, + OriginalMessageDismissedViolation, } from '@src/types/onyx/OriginalMessage'; import type Report from '@src/types/onyx/Report'; import type {Message, ReportActionBase, ReportActions} from '@src/types/onyx/ReportAction'; @@ -29,6 +30,7 @@ import type {MessageElementBase, MessageTextElement} from './MessageElement'; import * as PersonalDetailsUtils from './PersonalDetailsUtils'; import type {OptimisticIOUReportAction} from './ReportUtils'; import * as TransactionUtils from './TransactionUtils'; +import type {TranslationPaths} from '@src/languages/types'; type LastVisibleMessage = { lastMessageTranslationKey?: string; @@ -1108,10 +1110,10 @@ function getReportActionMessageText(reportAction: OnyxEntry | Empt return reportAction?.message?.reduce((acc, curr) => `${acc}${curr?.text}`, '') ?? ''; } -function getDismissedViolationMessageText(originalMessage): string { +function getDismissedViolationMessageText(originalMessage: OriginalMessageDismissedViolation['originalMessage']): string { const reason = originalMessage.reason; const violationName = originalMessage.violationName; - return Localize.translateLocal(`violationDismissal.${violationName}.${reason}`); + return Localize.translateLocal(`violationDismissal.${violationName}.${reason}` as TranslationPaths); } /** diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 853ca8485c4a..d27aa188a0f9 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -311,6 +311,14 @@ type OriginalMessageMoved = { }; }; +type OriginalMessageDismissedViolation = { + actionName: typeof CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION; + originalMessage: { + reason: string; + violationName: string; + }; +} + type OriginalMessage = | OriginalMessageApproved | OriginalMessageIOU @@ -334,7 +342,8 @@ type OriginalMessage = | OriginalMessageReimbursementDequeued | OriginalMessageMoved | OriginalMessageMarkedReimbursed - | OriginalMessageActionableTrackedExpenseWhisper; + | OriginalMessageActionableTrackedExpenseWhisper + | OriginalMessageDismissedViolation; export default OriginalMessage; export type { @@ -360,4 +369,5 @@ export type { DecisionName, PaymentMethodType, OriginalMessageActionableTrackedExpenseWhisper, + OriginalMessageDismissedViolation, }; From 003758b2ff16f28479305b52fdcd3ebb4eae050e Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Mon, 29 Apr 2024 18:23:50 -0700 Subject: [PATCH 3/7] ESLint --- src/libs/ReportActionsUtils.ts | 2 +- src/pages/home/report/ReportActionItem.tsx | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 1de5b8f57b80..71ef94b1a1d7 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -21,6 +21,7 @@ import type {Message, ReportActionBase, ReportActions} from '@src/types/onyx/Rep import type ReportAction from '@src/types/onyx/ReportAction'; import type {EmptyObject} from '@src/types/utils/EmptyObject'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; +import type {TranslationPaths} from '@src/languages/types'; import DateUtils from './DateUtils'; import * as Environment from './Environment/Environment'; import isReportMessageAttachment from './isReportMessageAttachment'; @@ -30,7 +31,6 @@ import type {MessageElementBase, MessageTextElement} from './MessageElement'; import * as PersonalDetailsUtils from './PersonalDetailsUtils'; import type {OptimisticIOUReportAction} from './ReportUtils'; import * as TransactionUtils from './TransactionUtils'; -import type {TranslationPaths} from '@src/languages/types'; type LastVisibleMessage = { lastMessageTranslationKey?: string; diff --git a/src/pages/home/report/ReportActionItem.tsx b/src/pages/home/report/ReportActionItem.tsx index fce49655c07d..81d59bb1588e 100644 --- a/src/pages/home/report/ReportActionItem.tsx +++ b/src/pages/home/report/ReportActionItem.tsx @@ -80,7 +80,6 @@ import ReportActionItemMessageEdit from './ReportActionItemMessageEdit'; import ReportActionItemSingle from './ReportActionItemSingle'; import ReportActionItemThread from './ReportActionItemThread'; import ReportAttachmentsContext from './ReportAttachmentsContext'; -import {getDismissedViolationMessageText} from "@libs/ReportActionsUtils"; const getDraftMessage = (drafts: OnyxCollection, reportID: string, action: OnyxTypes.ReportAction): string | undefined => { const originalReportID = ReportUtils.getOriginalReportID(reportID, action); From eeed97b0c5ee84b23b673a098165e5073ab95354 Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Mon, 29 Apr 2024 19:09:31 -0700 Subject: [PATCH 4/7] Pretier/Lint --- src/languages/en.ts | 6 +++--- src/languages/es.ts | 4 ++-- src/libs/ReportActionsUtils.ts | 4 ++-- src/types/onyx/OriginalMessage.ts | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 84573c09af2f..d8fa24d029b6 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2892,9 +2892,9 @@ export default { taxRequired: 'Missing tax rate', }, violationDismissal: { - rter:{ - manual: 'marked this receipt as cash, confirming it doesn\'t match a credit card transaction', - } + rter: { + manual: "marked this receipt as cash, confirming it doesn't match a credit card transaction", + }, }, videoPlayer: { play: 'Play', diff --git a/src/languages/es.ts b/src/languages/es.ts index e088b477f8a0..d645a323d492 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -3388,9 +3388,9 @@ export default { taxRequired: 'Falta la tasa de impuesto', }, violationDismissal: { - rter:{ + rter: { manual: 'marcó este recibo como efectivo, confirmando que no coincide con una transacción de tarjeta de crédito', - } + }, }, videoPlayer: { play: 'Reproducir', diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 71ef94b1a1d7..dc07f31c1067 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -5,23 +5,23 @@ import type {OnyxCollection, OnyxEntry, OnyxUpdate} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; import CONST from '@src/CONST'; +import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; import type { ActionName, ChangeLog, IOUMessage, OriginalMessageActionableMentionWhisper, + OriginalMessageDismissedViolation, OriginalMessageIOU, OriginalMessageJoinPolicyChangeLog, OriginalMessageReimbursementDequeued, - OriginalMessageDismissedViolation, } from '@src/types/onyx/OriginalMessage'; import type Report from '@src/types/onyx/Report'; import type {Message, ReportActionBase, ReportActions} from '@src/types/onyx/ReportAction'; import type ReportAction from '@src/types/onyx/ReportAction'; import type {EmptyObject} from '@src/types/utils/EmptyObject'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; -import type {TranslationPaths} from '@src/languages/types'; import DateUtils from './DateUtils'; import * as Environment from './Environment/Environment'; import isReportMessageAttachment from './isReportMessageAttachment'; diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index d27aa188a0f9..a746053be64e 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -317,7 +317,7 @@ type OriginalMessageDismissedViolation = { reason: string; violationName: string; }; -} +}; type OriginalMessage = | OriginalMessageApproved From a1477f637a54ec2ff87bf0b664fd13b5e8b3f62c Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Mon, 29 Apr 2024 21:09:46 -0700 Subject: [PATCH 5/7] Spanish tweak --- src/languages/es.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index d645a323d492..0a3b17560c61 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -3389,7 +3389,7 @@ export default { }, violationDismissal: { rter: { - manual: 'marcó este recibo como efectivo, confirmando que no coincide con una transacción de tarjeta de crédito', + manual: 'marcó este recibo como efectivo, confirmando que no corresponde a una transacción con tarjeta de crédito.', }, }, videoPlayer: { From ee7ff05a5ca2dea0fd2986d55eaa986d2ec85a52 Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Tue, 30 Apr 2024 11:42:47 -0700 Subject: [PATCH 6/7] Final opy tweak --- src/languages/en.ts | 2 +- src/languages/es.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index d8fa24d029b6..db4c214ea109 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2893,7 +2893,7 @@ export default { }, violationDismissal: { rter: { - manual: "marked this receipt as cash, confirming it doesn't match a credit card transaction", + manual: "marked this receipt as cash.", }, }, videoPlayer: { diff --git a/src/languages/es.ts b/src/languages/es.ts index 0a3b17560c61..09553f88f76a 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -3389,7 +3389,7 @@ export default { }, violationDismissal: { rter: { - manual: 'marcó este recibo como efectivo, confirmando que no corresponde a una transacción con tarjeta de crédito.', + manual: 'marcó el recibo como pagado en efectivo.', }, }, videoPlayer: { From f7bbab4cffd9d1822241a099eb71c564ee285f8e Mon Sep 17 00:00:00 2001 From: Yuwen Memon Date: Wed, 1 May 2024 00:08:14 -0700 Subject: [PATCH 7/7] Prettier --- src/languages/en.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index db4c214ea109..23e931ddb310 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2893,7 +2893,7 @@ export default { }, violationDismissal: { rter: { - manual: "marked this receipt as cash.", + manual: 'marked this receipt as cash.', }, }, videoPlayer: {