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

Add support for DISMISSED_VIOLATION system message #41051

Merged
merged 8 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,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
Expand Down
5 changes: 5 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2891,6 +2891,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',
Expand Down
5 changes: 5 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3387,6 +3387,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 corresponde a una transacción con tarjeta de crédito.',
},
},
videoPlayer: {
play: 'Reproducir',
pause: 'Pausar',
Expand Down
9 changes: 9 additions & 0 deletions src/libs/ReportActionsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ 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,
Expand Down Expand Up @@ -1108,6 +1110,12 @@ function getReportActionMessageText(reportAction: OnyxEntry<ReportAction> | Empt
return reportAction?.message?.reduce((acc, curr) => `${acc}${curr?.text}`, '') ?? '';
}

function getDismissedViolationMessageText(originalMessage: OriginalMessageDismissedViolation['originalMessage']): string {
const reason = originalMessage.reason;
const violationName = originalMessage.violationName;
return Localize.translateLocal(`violationDismissal.${violationName}.${reason}` as TranslationPaths);
}

/**
* Check if the linked transaction is on hold
*/
Expand All @@ -1117,6 +1125,7 @@ function isLinkedTransactionHeld(reportActionID: string, reportID: string): bool

export {
extractLinksFromMessageHtml,
getDismissedViolationMessageText,
getOneTransactionThreadReportID,
getIOUReportIDFromReportActionPreview,
getLastClosedReportAction,
Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,8 @@ function ReportActionItem({
children = <ReportActionItemBasicMessage message={action.message?.[0]?.text ?? ''} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.UNHOLD) {
children = <ReportActionItemBasicMessage message={translate('iou.unheldExpense')} />;
} else if (action.actionName === CONST.REPORT.ACTIONS.TYPE.DISMISSED_VIOLATION) {
children = <ReportActionItemBasicMessage message={ReportActionsUtils.getDismissedViolationMessageText(action.originalMessage)} />;
arosiclair marked this conversation as resolved.
Show resolved Hide resolved
} else {
const hasBeenFlagged =
![CONST.MODERATION.MODERATOR_DECISION_APPROVED, CONST.MODERATION.MODERATOR_DECISION_PENDING].some((item) => item === moderationDecision) &&
Expand Down
12 changes: 11 additions & 1 deletion src/types/onyx/OriginalMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -334,7 +342,8 @@ type OriginalMessage =
| OriginalMessageReimbursementDequeued
| OriginalMessageMoved
| OriginalMessageMarkedReimbursed
| OriginalMessageActionableTrackedExpenseWhisper;
| OriginalMessageActionableTrackedExpenseWhisper
| OriginalMessageDismissedViolation;

export default OriginalMessage;
export type {
Expand All @@ -360,4 +369,5 @@ export type {
DecisionName,
PaymentMethodType,
OriginalMessageActionableTrackedExpenseWhisper,
OriginalMessageDismissedViolation,
};
Loading