Skip to content

Commit

Permalink
different messages if submitter when dismissing violation
Browse files Browse the repository at this point in the history
  • Loading branch information
rlinoz committed Jul 11, 2024
1 parent 28e5e45 commit 93ef028
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/libs/API/parameters/DismissViolationParams.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
type DismissViolationParams = {
name: string;
transactionIDList: string;
reportActionIDList: string;
};

export default DismissViolationParams;
18 changes: 14 additions & 4 deletions src/libs/actions/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import type {DismissViolationParams, GetRouteParams, MarkAsCashParams} from '@li
import {READ_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
import * as CollectionUtils from '@libs/CollectionUtils';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import {buildOptimisticDismissedViolationReportAction} from '@libs/ReportUtils';
import {
buildOptimisticDismissedViolationReportAction,
buildOptimisticUnHoldReportAction,
isCurrentUserSubmitter
} from '@libs/ReportUtils';
import * as TransactionUtils from '@libs/TransactionUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -292,9 +296,14 @@ function dismissDuplicateTransactionViolation(transactionIDs: string[], dissmiss
const currentTransactionViolations = transactionIDs.map((id) => ({transactionID: id, violations: allTransactionViolation?.[id] ?? []}));
const currentTransactions = transactionIDs.map((id) => allTransactions?.[id]);
const transactionsReportActions = currentTransactions.map((transaction) => ReportActionsUtils.getIOUActionForReportID(transaction.reportID ?? '', transaction.transactionID ?? ''));
const optimisticDissmidedViolationReportActions = transactionsReportActions.map(() =>
buildOptimisticDismissedViolationReportAction({reason: 'manual', violationName: CONST.VIOLATIONS.DUPLICATED_TRANSACTION}),
);
const isSubmitter = currentTransactions.every((transaction) => isCurrentUserSubmitter(transaction.reportID ?? ''));
const optimisticDissmidedViolationReportActions = transactionsReportActions.map(() => {
if (isSubmitter) {
return buildOptimisticUnHoldReportAction();
}
return buildOptimisticDismissedViolationReportAction({reason: 'manual', violationName: CONST.VIOLATIONS.DUPLICATED_TRANSACTION});
});

const optimisticData: OnyxUpdate[] = [];
const failureData: OnyxUpdate[] = [];

Expand Down Expand Up @@ -371,6 +380,7 @@ function dismissDuplicateTransactionViolation(transactionIDs: string[], dissmiss
const params: DismissViolationParams = {
name: CONST.VIOLATIONS.DUPLICATED_TRANSACTION,
transactionIDList: transactionIDs.join(','),
reportActionIDList: optimisticDissmidedViolationReportActions.map((action) => action.reportActionID).join(','),
};

API.write(WRITE_COMMANDS.DISMISS_VIOLATION, params, {
Expand Down

0 comments on commit 93ef028

Please sign in to comment.