Skip to content

Commit

Permalink
Merge pull request #47688 from bernhardoj/fix/46158-hold-text-isn't-s…
Browse files Browse the repository at this point in the history
…hown

Prioritize hold violation message on money request preview
  • Loading branch information
roryabraham authored Aug 23, 2024
2 parents cf81760 + dd42e41 commit bccfa32
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ function MoneyRequestPreviewContent({

const shouldShowRBR = hasNoticeTypeViolations || hasViolations || hasFieldErrors || (!isFullySettled && !isFullyApproved && isOnHold) || hasDuplicates;
const showCashOrCard = isCardTransaction ? translate('iou.card') : translate('iou.cash');
const shouldShowHoldMessage = !(isSettled && !isSettlementOrApprovalPartial) && isOnHold;
// We don't use isOnHold because it's true for duplicated transaction too and we only want to show hold message if the transaction is truly on hold
const shouldShowHoldMessage = !(isSettled && !isSettlementOrApprovalPartial) && !!transaction?.comment?.hold;

const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${route.params?.threadReportID}`);
const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '', report?.parentReportActionID ?? '');
Expand Down Expand Up @@ -192,9 +193,10 @@ function MoneyRequestPreviewContent({
}

if (shouldShowRBR && transaction) {
const violations = TransactionUtils.getTransactionViolations(transaction.transactionID, transactionViolations)?.sort((a) =>
a.type === CONST.VIOLATION_TYPES.VIOLATION ? -1 : 0,
);
const violations = TransactionUtils.getTransactionViolations(transaction.transactionID, transactionViolations);
if (shouldShowHoldMessage) {
return `${message} ${CONST.DOT_SEPARATOR} ${translate('violations.hold')}`;
}
if (violations?.[0]) {
const violationMessage = ViolationsUtils.getViolationTranslation(violations[0], translate);
const violationsCount = violations.filter((v) => v.type === CONST.VIOLATION_TYPES.VIOLATION).length;
Expand All @@ -215,9 +217,6 @@ function MoneyRequestPreviewContent({
}
return message;
}
if (shouldShowHoldMessage) {
message += ` ${CONST.DOT_SEPARATOR} ${translate('violations.hold')}`;
}
} else if (hasNoticeTypeViolations && transaction && !ReportUtils.isReportApproved(iouReport) && !ReportUtils.isSettled(iouReport?.reportID)) {
message += ` • ${translate('violations.reviewRequired')}`;
} else if (ReportUtils.isPaidGroupPolicyExpenseReport(iouReport) && ReportUtils.isReportApproved(iouReport) && !ReportUtils.isSettled(iouReport?.reportID) && !isPartialHold) {
Expand Down

0 comments on commit bccfa32

Please sign in to comment.