From 79483316b06c811dc63524f8c6a613fc8a8bcf5d Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Tue, 20 Aug 2024 16:48:38 +0800 Subject: [PATCH 1/2] prioritize hold violation --- .../MoneyRequestPreview/MoneyRequestPreviewContent.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx index 8597654576fc..f9d6a89b6f53 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx @@ -192,9 +192,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; @@ -215,9 +216,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) { From dd42e41686aa8ff3970e5bda74ae76e86cdc6344 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 22 Aug 2024 23:55:11 +0800 Subject: [PATCH 2/2] only show hold message if the transaction is truly on hold --- .../MoneyRequestPreview/MoneyRequestPreviewContent.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx index f9d6a89b6f53..ac61cb74d229 100644 --- a/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx @@ -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 ?? '');