diff --git a/src/CONST.ts b/src/CONST.ts index 6a15217ddd49..419495d43378 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -4739,6 +4739,11 @@ const CONST = { SMARTSCAN: 'smartscan', }, + /** + * Constants for violation names that we don't want to show on NewDot + */ + EXCLUDED_VIOLATIONS: ['taxAmountChanged', 'taxRateChanged'], + /** * Constants for types of violation names. * Defined here because they need to be referenced by the type system to generate the diff --git a/src/hooks/useViolations.ts b/src/hooks/useViolations.ts index 5eb77f2d45e7..2eefdeee4797 100644 --- a/src/hooks/useViolations.ts +++ b/src/hooks/useViolations.ts @@ -1,4 +1,5 @@ import {useCallback, useMemo} from 'react'; +import type {TupleToUnion} from 'type-fest'; import CONST from '@src/CONST'; import type {TransactionViolation, ViolationName} from '@src/types/onyx'; @@ -49,9 +50,6 @@ const violationFields: Record = { type ViolationsMap = Map; -// We don't want to show these violations on NewDot -const excludedViolationsName = ['taxAmountChanged', 'taxRateChanged']; - /** * @param violations – List of transaction violations * @param shouldShowOnlyViolations – Whether we should only show violations of type 'violation' @@ -59,7 +57,8 @@ const excludedViolationsName = ['taxAmountChanged', 'taxRateChanged']; function useViolations(violations: TransactionViolation[], shouldShowOnlyViolations: boolean) { const violationsByField = useMemo((): ViolationsMap => { const filteredViolations = violations.filter((violation) => { - if (excludedViolationsName.includes(violation.name)) { + // We don't want to show these violations on NewDot + if (CONST.EXCLUDED_VIOLATIONS.includes(violation.name as TupleToUnion)) { return false; } if (shouldShowOnlyViolations) { diff --git a/src/pages/Debug/const.ts b/src/pages/Debug/const.ts index b98741228d6b..e3cd60fcd92f 100644 --- a/src/pages/Debug/const.ts +++ b/src/pages/Debug/const.ts @@ -1,4 +1,4 @@ -import type {ValueOf} from 'type-fest'; +import type {TupleToUnion, ValueOf} from 'type-fest'; import CONST from '@src/CONST'; import ACTION_FORM_INPUT_IDS from '@src/types/form/DebugReportActionForm'; import REPORT_FORM_INPUT_IDS from '@src/types/form/DebugReportForm'; @@ -110,7 +110,7 @@ const DETAILS_CONSTANT_FIELDS: DetailsConstantFields = { [CONST.DEBUG.FORMS.TRANSACTION_VIOLATION]: [ { fieldName: TRANSACTION_VIOLATION_FORM_INPUT_IDS.NAME, - options: CONST.VIOLATIONS, + options: Object.fromEntries(Object.entries(CONST.VIOLATIONS).filter(([, value]) => !CONST.EXCLUDED_VIOLATIONS.includes(value as TupleToUnion))), }, { fieldName: TRANSACTION_VIOLATION_FORM_INPUT_IDS.TYPE,