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

Fix violation shows optimistically for a partial transaction #39034

23 changes: 13 additions & 10 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -807,16 +807,18 @@ function buildOnyxDataForMoneyRequest(
if (!policy || !PolicyUtils.isPaidGroupPolicy(policy)) {
return [optimisticData, successData, failureData];
}
const isPartialTransaction = TransactionUtils.isMerchantMissing(transaction) && TransactionUtils.isAmountMissing(transaction);
bernhardoj marked this conversation as resolved.
Show resolved Hide resolved
if (!isPartialTransaction) {
const violationsOnyxData = ViolationsUtils.getViolationsOnyxData(transaction, [], !!policy.requiresTag, policyTagList ?? {}, !!policy.requiresCategory, policyCategories ?? {});

const violationsOnyxData = ViolationsUtils.getViolationsOnyxData(transaction, [], !!policy.requiresTag, policyTagList ?? {}, !!policy.requiresCategory, policyCategories ?? {});

if (violationsOnyxData) {
optimisticData.push(violationsOnyxData);
failureData.push({
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction.transactionID}`,
value: [],
});
if (violationsOnyxData) {
optimisticData.push(violationsOnyxData);
failureData.push({
onyxMethod: Onyx.METHOD.SET,
key: `${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transaction.transactionID}`,
value: [],
});
}
}

return [optimisticData, successData, failureData];
Expand Down Expand Up @@ -1698,7 +1700,8 @@ function getUpdateMoneyRequestParams(
});
}

if (policy && PolicyUtils.isPaidGroupPolicy(policy) && updatedTransaction) {
const isPartialTransaction = TransactionUtils.isMerchantMissing(updatedTransaction) && TransactionUtils.isAmountMissing(updatedTransaction);
if (policy && PolicyUtils.isPaidGroupPolicy(policy) && updatedTransaction && !isPartialTransaction) {
bernhardoj marked this conversation as resolved.
Show resolved Hide resolved
const currentTransactionViolations = allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`] ?? [];
optimisticData.push(
ViolationsUtils.getViolationsOnyxData(
Expand Down
Loading