Skip to content

Commit

Permalink
Merge pull request #47607 from bernhardoj/fix/47411-no-rbr-when-there…
Browse files Browse the repository at this point in the history
…-is-amount-or-date-unmatch-violation
  • Loading branch information
francoisl authored Aug 22, 2024
2 parents 91305a8 + 0533160 commit bdeab94
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/LHNOptionsList/LHNOptionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ function LHNOptionsList({style, contentContainerStyles, data, onSelectRow, optio
);

const extraData = useMemo(
() => [reportActions, reports, policy, personalDetails, data.length, draftComments, optionMode, preferredLocale],
[reportActions, reports, policy, personalDetails, data.length, draftComments, optionMode, preferredLocale],
() => [reportActions, reports, transactionViolations, policy, personalDetails, data.length, draftComments, optionMode, preferredLocale],
[reportActions, reports, transactionViolations, policy, personalDetails, data.length, draftComments, optionMode, preferredLocale],
);

const previousOptionMode = usePrevious(optionMode);
Expand Down
6 changes: 5 additions & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5813,7 +5813,11 @@ function doesTransactionThreadHaveViolations(
if (report?.stateNum !== CONST.REPORT.STATE_NUM.OPEN && report?.stateNum !== CONST.REPORT.STATE_NUM.SUBMITTED) {
return false;
}
return TransactionUtils.hasViolation(IOUTransactionID, transactionViolations) || TransactionUtils.hasWarningTypeViolation(IOUTransactionID, transactionViolations);
return (
TransactionUtils.hasViolation(IOUTransactionID, transactionViolations) ||
TransactionUtils.hasWarningTypeViolation(IOUTransactionID, transactionViolations) ||
TransactionUtils.hasModifiedAmountOrDateViolation(IOUTransactionID, transactionViolations)
);
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,15 @@ function hasWarningTypeViolation(transactionID: string, transactionViolations: O
return !!transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID]?.some((violation: TransactionViolation) => violation.type === CONST.VIOLATION_TYPES.WARNING);
}

/**
* Checks if any violations for the provided transaction are of modifiedAmount or modifiedDate
*/
function hasModifiedAmountOrDateViolation(transactionID: string, transactionViolations: OnyxCollection<TransactionViolation[]>): boolean {
return !!transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID]?.some(
(violation: TransactionViolation) => violation.name === CONST.VIOLATIONS.MODIFIED_AMOUNT || violation.name === CONST.VIOLATIONS.MODIFIED_DATE,
);
}

/**
* Calculates tax amount from the given expense amount and tax percentage
*/
Expand Down Expand Up @@ -1106,6 +1115,7 @@ export {
hasViolation,
hasNoticeTypeViolation,
hasWarningTypeViolation,
hasModifiedAmountOrDateViolation,
isCustomUnitRateIDForP2P,
getRateID,
getTransaction,
Expand Down

0 comments on commit bdeab94

Please sign in to comment.