Skip to content

Commit

Permalink
show field violations only for control policies
Browse files Browse the repository at this point in the history
  • Loading branch information
war-in committed Aug 8, 2024
1 parent 68ee76b commit 2a61a4b
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -897,10 +897,6 @@ function buildOnyxDataForMoneyRequest(
return [optimisticData, successData, failureData];
}

const {optimisticData: fieldViolationsOptimisticData, failureData: fieldViolationsFailureData} = getFieldViolationsOnyxData(iouReport);
optimisticData.push(...fieldViolationsOptimisticData);
failureData.push(...fieldViolationsFailureData);

const violationsOnyxData = ViolationsUtils.getViolationsOnyxData(
transaction,
[],
Expand All @@ -920,6 +916,13 @@ function buildOnyxDataForMoneyRequest(
});
}

// Show field violations only for control policies
if (PolicyUtils.isControlPolicy(policy)) {
const {optimisticData: fieldViolationsOptimisticData, failureData: fieldViolationsFailureData} = getFieldViolationsOnyxData(iouReport);
optimisticData.push(...fieldViolationsOptimisticData);
failureData.push(...fieldViolationsFailureData);
}

return [optimisticData, successData, failureData];
}

Expand Down Expand Up @@ -1600,12 +1603,6 @@ function buildOnyxDataForTrackExpense(
return [optimisticData, successData, failureData];
}

if (iouReport) {
const {optimisticData: fieldViolationsOptimisticData, failureData: fieldViolationsFailureData} = getFieldViolationsOnyxData(iouReport);
optimisticData.push(...fieldViolationsOptimisticData);
failureData.push(...fieldViolationsFailureData);
}

const violationsOnyxData = ViolationsUtils.getViolationsOnyxData(
transaction,
[],
Expand All @@ -1625,6 +1622,13 @@ function buildOnyxDataForTrackExpense(
});
}

// Show field violations only for control policies
if (PolicyUtils.isControlPolicy(policy) && iouReport) {
const {optimisticData: fieldViolationsOptimisticData, failureData: fieldViolationsFailureData} = getFieldViolationsOnyxData(iouReport);
optimisticData.push(...fieldViolationsOptimisticData);
failureData.push(...fieldViolationsFailureData);
}

return [optimisticData, successData, failureData];
}

Expand Down

0 comments on commit 2a61a4b

Please sign in to comment.