Skip to content

Commit

Permalink
Merge pull request #32696 from Expensify/cmartins-updateDeleteMoneyRe…
Browse files Browse the repository at this point in the history
…questForViolations
  • Loading branch information
cead22 authored Dec 12, 2023
2 parents e002ebd + c90377e commit 617c2dd
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/libs/actions/IOU.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import * as Localize from '@libs/Localize';
import Navigation from '@libs/Navigation/Navigation';
import * as NumberUtils from '@libs/NumberUtils';
import * as OptionsListUtils from '@libs/OptionsListUtils';
import Permissions from '@libs/Permissions';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
import * as TransactionUtils from '@libs/TransactionUtils';
Expand All @@ -25,6 +26,12 @@ import ROUTES from '@src/ROUTES';
import * as Policy from './Policy';
import * as Report from './Report';

let betas;
Onyx.connect({
key: ONYXKEYS.BETAS,
callback: (val) => (betas = val || []),
});

let allPersonalDetails;
Onyx.connect({
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
Expand Down Expand Up @@ -54,6 +61,20 @@ Onyx.connect({
},
});

let allTransactionViolations;
Onyx.connect({
key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (val) => {
if (!val) {
allTransactionViolations = {};
return;
}

allTransactionViolations = val;
},
});

let allDraftSplitTransactions;
Onyx.connect({
key: ONYXKEYS.COLLECTION.SPLIT_TRANSACTION_DRAFT,
Expand Down Expand Up @@ -2149,6 +2170,7 @@ function deleteMoneyRequest(transactionID, reportAction, isSingleTransactionView
const chatReport = allReports[`${ONYXKEYS.COLLECTION.REPORT}${iouReport.chatReportID}`];
const reportPreviewAction = ReportActionsUtils.getReportPreviewAction(iouReport.chatReportID, iouReport.reportID);
const transaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
const transactionViolations = allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`];
const transactionThreadID = reportAction.childReportID;
let transactionThread = null;
if (transactionThreadID) {
Expand Down Expand Up @@ -2229,6 +2251,15 @@ function deleteMoneyRequest(transactionID, reportAction, isSingleTransactionView
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: null,
},
...(Permissions.canUseViolations(betas)
? [
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`,
value: null,
},
]
: []),
...(shouldDeleteTransactionThread
? [
{
Expand Down Expand Up @@ -2292,6 +2323,15 @@ function deleteMoneyRequest(transactionID, reportAction, isSingleTransactionView
key: `${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`,
value: transaction,
},
...(Permissions.canUseViolations(betas)
? [
{
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`,
value: transactionViolations,
},
]
: []),
...(shouldDeleteTransactionThread
? [
{
Expand Down

0 comments on commit 617c2dd

Please sign in to comment.