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

Debug - There is no error message when selecting taxAmountChanged violation #53097

Closed
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/hooks/useViolations.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -49,17 +50,15 @@ const violationFields: Record<ViolationName, ViolationField> = {

type ViolationsMap = Map<ViolationField, TransactionViolation[]>;

// 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'
*/
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<typeof CONST.EXCLUDED_VIOLATIONS>)) {
return false;
}
if (shouldShowOnlyViolations) {
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Debug/const.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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<typeof CONST.EXCLUDED_VIOLATIONS>))),
},
{
fieldName: TRANSACTION_VIOLATION_FORM_INPUT_IDS.TYPE,
Expand Down
Loading