Skip to content

Commit 7bea8cb

Browse files
committed
fix violations
1 parent 74eda53 commit 7bea8cb

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

src/libs/actions/Transaction.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -741,20 +741,31 @@ function changeTransactionsReport(transactionIDs: string[], reportID: string) {
741741

742742
// Optimistically clear all violations for the transaction when moving to self DM report
743743
if (reportID === CONST.REPORT.UNREPORTED_REPORT_ID) {
744+
const duplicateViolation = currentTransactionViolations?.[transaction.transactionID]?.find((violation) => violation.name === CONST.VIOLATIONS.DUPLICATED_TRANSACTION);
745+
const duplicateTransactionIDs = duplicateViolation?.data?.duplicates;
746+
if (duplicateTransactionIDs) {
747+
duplicateTransactionIDs.forEach((id) => {
748+
optimisticData.push({
749+
onyxMethod: Onyx.METHOD.SET,
750+
key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${id}`,
751+
value: allTransactionViolations.filter((violation: TransactionViolation) => violation.name !== CONST.VIOLATIONS.DUPLICATED_TRANSACTION),
752+
});
753+
});
754+
}
744755
optimisticData.push({
745-
onyxMethod: Onyx.METHOD.MERGE,
756+
onyxMethod: Onyx.METHOD.SET,
746757
key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction.transactionID}`,
747-
value: [],
758+
value: null,
748759
});
749760

750761
successData.push({
751-
onyxMethod: Onyx.METHOD.MERGE,
762+
onyxMethod: Onyx.METHOD.SET,
752763
key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction.transactionID}`,
753-
value: [],
764+
value: null,
754765
});
755766

756767
failureData.push({
757-
onyxMethod: Onyx.METHOD.MERGE,
768+
onyxMethod: Onyx.METHOD.SET,
758769
key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction.transactionID}`,
759770
value: currentTransactionViolations[transaction.transactionID],
760771
});

0 commit comments

Comments
 (0)