Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type ChangeTransactionsReportParams = {
transactionList: string;
reportID: string;
transactionIDToReportActionAndThreadData: string; // A map of transactionID to TransactionThreadInfo
transactionIDToUpdatedCustomUnitRateID?: string; // A JSON map of transactionID to the new customUnitRateID (for distance expenses moving to a workspace with an invalid rate)
};

export type {ChangeTransactionsReportParams, TransactionThreadInfo};
9 changes: 6 additions & 3 deletions src/libs/Violations/ViolationsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ const ViolationsUtils = {
hasDependentTags,
isInvoiceTransaction,
isSelfDM,
isTransactionOnPolicyExpenseChat,
iouReport,
isFromExpenseReport,
shouldRemoveRejectedExpenseViolation,
Expand All @@ -481,6 +482,7 @@ const ViolationsUtils = {
hasDependentTags: boolean;
isInvoiceTransaction: boolean;
isSelfDM?: boolean;
isTransactionOnPolicyExpenseChat?: boolean;
iouReport?: OnyxEntry<Report>;
isFromExpenseReport?: boolean;
shouldRemoveRejectedExpenseViolation?: boolean;
Expand Down Expand Up @@ -652,8 +654,8 @@ const ViolationsUtils = {
// arrives). We must NOT clear it when the transaction is still bound to a policy expense chat, because a
// track expense moved onto a workspace intentionally keeps FAKE_P2P_ID until the user picks a workspace
// rate, and the violation is what prompts them to do so — so that case falls through to the rate check below.
const isTransactionOnPolicyExpenseChat = updatedTransaction.participants?.some((participant) => participant?.isPolicyExpenseChat);
if (TransactionUtils.isCustomUnitRateIDForP2P(updatedTransaction) && !isTransactionOnPolicyExpenseChat) {
const isOnPolicyExpenseChat = isTransactionOnPolicyExpenseChat ?? updatedTransaction.participants?.some((participant) => participant?.isPolicyExpenseChat);
if (TransactionUtils.isCustomUnitRateIDForP2P(updatedTransaction) && !isOnPolicyExpenseChat) {
newTransactionViolations = reject(newTransactionViolations, {name: CONST.VIOLATIONS.CUSTOM_UNIT_OUT_OF_POLICY});
} else {
const isPerDiem = TransactionUtils.isPerDiemRequest(updatedTransaction);
Expand All @@ -664,7 +666,8 @@ const ViolationsUtils = {
}

const customRate = isPerDiem ? getPerDiemRateCustomUnitRate(policy, customUnitRateID) : getDistanceRateCustomUnitRate(policyForCustomUnitRate, customUnitRateID);
if (customRate && customRate.enabled !== false) {
const isRatePendingDeletion = customRate?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
if (customRate && !isRatePendingDeletion) {
newTransactionViolations = reject(newTransactionViolations, {name: CONST.VIOLATIONS.CUSTOM_UNIT_OUT_OF_POLICY});
newTransactionViolations = syncCustomUnitRateOutOfDateRangeViolation(newTransactionViolations, updatedTransaction, policyForCustomUnitRate);
} else if (isSelfDM && isDistanceRequestForCustomUnit) {
Expand Down
Loading
Loading