From 5250878ba22a15d303b07a342aaa2bf39b2a3105 Mon Sep 17 00:00:00 2001 From: Kevin Brian Bader Date: Fri, 25 Oct 2024 14:08:10 -0700 Subject: [PATCH] Approval button is missing after payment of the report with hold expense --- src/libs/actions/IOU.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 7ce9b9dfb272..a742f700233b 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -7035,9 +7035,19 @@ function canApproveIOU(iouReport: OnyxTypes.OnyxInputOrEntry, const iouSettled = ReportUtils.isSettled(iouReport?.reportID); const reportNameValuePairs = ReportUtils.getReportNameValuePairs(iouReport?.reportID); const isArchivedReport = ReportUtils.isArchivedRoom(iouReport, reportNameValuePairs); - const unheldTotalIsZero = iouReport && iouReport.unheldTotal === 0; + let isTransactionBeingScanned = false; + const reportTransactions = TransactionUtils.getAllReportTransactions(iouReport?.reportID); + for (const transaction of reportTransactions) { + const hasReceipt = TransactionUtils.hasReceipt(transaction); + const isReceiptBeingScanned = TransactionUtils.isReceiptBeingScanned(transaction); + + // If transaction has receipt (scan) and its receipt is being scanned, we shouldn't be able to Approve + if (hasReceipt && isReceiptBeingScanned) { + isTransactionBeingScanned = true; + } + } - return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled && !isArchivedReport && !unheldTotalIsZero; + return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled && !isArchivedReport && !isTransactionBeingScanned; } function canIOUBePaid(