Skip to content

Commit

Permalink
Always Display 'Review required' if there is a violations error
Browse files Browse the repository at this point in the history
  • Loading branch information
Shahe Shahinyan committed Mar 4, 2024
1 parent 5f350ea commit a7b6d6a
Showing 1 changed file with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,27 +152,25 @@ function MoneyRequestPreviewContent({

let message = translate('iou.cash');
if (shouldShowRBR && transaction) {
if (hasFieldErrors) {
const isMerchantMissing = TransactionUtils.isMerchantMissing(transaction);
const isAmountMissing = TransactionUtils.isAmountMissing(transaction);

if (isAmountMissing && isMerchantMissing) {
message += ` • ${translate('violations.reviewRequired')}`;
} else if (isAmountMissing) {
message += ` • ${translate('iou.missingAmount')}`;
} else {
message += ` • ${translate('iou.missingMerchant')}`;
}

return message;
}

const violations = TransactionUtils.getTransactionViolations(transaction.transactionID, transactionViolations);
if (violations?.[0]) {
const violationMessage = ViolationsUtils.getViolationTranslation(violations[0], translate);
const isTooLong = violations.filter((v) => v.type === 'violation').length > 1 || violationMessage.length > 15;
message += ` • ${isTooLong ? translate('violations.reviewRequired') : violationMessage}`;

return `${message}${isTooLong ? translate('violations.reviewRequired') : violationMessage}`;
}

const isMerchantMissing = TransactionUtils.isMerchantMissing(transaction);
const isAmountMissing = TransactionUtils.isAmountMissing(transaction);

if (isAmountMissing && isMerchantMissing) {
message += ` • ${translate('violations.reviewRequired')}`;
} else if (isAmountMissing) {
message += ` • ${translate('iou.missingAmount')}`;
} else {
message += ` • ${translate('iou.missingMerchant')}`;
}

} else if (ReportUtils.isPaidGroupPolicyExpenseReport(iouReport) && ReportUtils.isReportApproved(iouReport) && !ReportUtils.isSettled(iouReport?.reportID)) {
message += ` • ${translate('iou.approved')}`;
} else if (iouReport?.isWaitingOnBankAccount) {
Expand Down

0 comments on commit a7b6d6a

Please sign in to comment.