From 788f07f76a4f23ae6aba52e3eccadd2b76ba63b0 Mon Sep 17 00:00:00 2001 From: BlameGPT <42474517+BlameGPT@users.noreply.github.com> Date: Tue, 15 Jul 2025 13:28:23 +0300 Subject: [PATCH 01/14] Fix submit button color for reopened report --- .../MoneyRequestReportPreviewContent.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index 12035cddd621..18cce61917ba 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -50,11 +50,13 @@ import { hasNonReimbursableTransactions as hasNonReimbursableTransactionsReportUtils, hasOnlyHeldExpenses as hasOnlyHeldExpensesReportUtils, hasOnlyTransactionsWithPendingRoutes as hasOnlyTransactionsWithPendingRoutesReportUtils, + hasReportBeenReopened, hasUpdatedTotal, isInvoiceReport as isInvoiceReportUtils, isInvoiceRoom as isInvoiceRoomReportUtils, isPolicyExpenseChat as isPolicyExpenseChatReportUtils, isReportApproved, + isReportOwner, isSettled, isTripRoom as isTripRoomReportUtils, isWaitingForSubmissionFromCurrentUser as isWaitingForSubmissionFromCurrentUserReportUtils, @@ -192,10 +194,16 @@ function MoneyRequestReportPreviewContent({ const hasReceipts = transactionsWithReceipts.length > 0; const isScanning = hasReceipts && areAllRequestsBeingSmartScanned; - // The submit button should be success green color only if the user is submitter and the policy does not have Scheduled Submit turned on - const isWaitingForSubmissionFromCurrentUser = useMemo(() => isWaitingForSubmissionFromCurrentUserReportUtils(chatReport, policy), [chatReport, policy]); const {isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext); const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, {canBeMissing: true}); + + // The submit button should be success green color only if the user is submitter and the policy does not have Scheduled Submit turned on + // Or if the report has been reopened + const isWaitingForSubmissionFromCurrentUser = useMemo(() => { + const isOwnAndReportHasBeenReopened = hasReportBeenReopened(reportActions) && isReportOwner(iouReport); + return isOwnAndReportHasBeenReopened || isWaitingForSubmissionFromCurrentUserReportUtils(chatReport, policy); + }, [chatReport, policy, reportActions, iouReport]); + const confirmPayment = useCallback( (type: PaymentMethodType | undefined, payAsBusiness?: boolean) => { if (!type) { From 5f69d0eb647186921d89297f8e5065f82077850b Mon Sep 17 00:00:00 2001 From: BlameGPT <42474517+BlameGPT@users.noreply.github.com> Date: Wed, 16 Jul 2025 13:38:56 +0300 Subject: [PATCH 02/14] Update MoneyRequestReportPreviewContent.tsx --- .../MoneyRequestReportPreviewContent.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index 18cce61917ba..0d8a8293186d 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -50,7 +50,6 @@ import { hasNonReimbursableTransactions as hasNonReimbursableTransactionsReportUtils, hasOnlyHeldExpenses as hasOnlyHeldExpensesReportUtils, hasOnlyTransactionsWithPendingRoutes as hasOnlyTransactionsWithPendingRoutesReportUtils, - hasReportBeenReopened, hasUpdatedTotal, isInvoiceReport as isInvoiceReportUtils, isInvoiceRoom as isInvoiceRoomReportUtils, @@ -197,12 +196,15 @@ function MoneyRequestReportPreviewContent({ const {isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext); const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, {canBeMissing: true}); + const hasReportBeenReopened = report.hasReportBeenReopened ?? false; + const hasReportBeenRetracted = report.hasReportBeenRetracted ?? false; + // The submit button should be success green color only if the user is submitter and the policy does not have Scheduled Submit turned on // Or if the report has been reopened const isWaitingForSubmissionFromCurrentUser = useMemo(() => { - const isOwnAndReportHasBeenReopened = hasReportBeenReopened(reportActions) && isReportOwner(iouReport); + const isOwnAndReportHasBeenRetracted = hasReportBeenReopened && isReportOwner(iouReport) || hasReportBeenRetracted && isReportOwner(iouReport); return isOwnAndReportHasBeenReopened || isWaitingForSubmissionFromCurrentUserReportUtils(chatReport, policy); - }, [chatReport, policy, reportActions, iouReport]); + }, [chatReport, policy, hasReportBeenReopened, hasReportBeenRetracted, iouReport]); const confirmPayment = useCallback( (type: PaymentMethodType | undefined, payAsBusiness?: boolean) => { From 256a52c09f3cde3efca8c53f51f6bdd5847a9378 Mon Sep 17 00:00:00 2001 From: BlameGPT <42474517+BlameGPT@users.noreply.github.com> Date: Wed, 16 Jul 2025 15:59:50 +0300 Subject: [PATCH 03/14] Update src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx --- .../MoneyRequestReportPreviewContent.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index 0d8a8293186d..04dd887c498f 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -200,7 +200,7 @@ function MoneyRequestReportPreviewContent({ const hasReportBeenRetracted = report.hasReportBeenRetracted ?? false; // The submit button should be success green color only if the user is submitter and the policy does not have Scheduled Submit turned on - // Or if the report has been reopened + // Or if the report has been reopened or retracted const isWaitingForSubmissionFromCurrentUser = useMemo(() => { const isOwnAndReportHasBeenRetracted = hasReportBeenReopened && isReportOwner(iouReport) || hasReportBeenRetracted && isReportOwner(iouReport); return isOwnAndReportHasBeenReopened || isWaitingForSubmissionFromCurrentUserReportUtils(chatReport, policy); From da2d06d9a66f6048d2e81fbbbc08743372bf4611 Mon Sep 17 00:00:00 2001 From: BlameGPT <42474517+BlameGPT@users.noreply.github.com> Date: Mon, 28 Jul 2025 15:44:19 +0300 Subject: [PATCH 04/14] Update src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx Co-authored-by: Rushat Gabhane --- .../MoneyRequestReportPreviewContent.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index 0dd04e60e986..e46ee75ebef0 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -189,7 +189,7 @@ function MoneyRequestReportPreviewContent({ // The submit button should be success green color only if the user is submitter and the policy does not have Scheduled Submit turned on // Or if the report has been reopened or retracted const isWaitingForSubmissionFromCurrentUser = useMemo(() => { - const isOwnAndReportHasBeenRetracted = hasReportBeenReopened && isReportOwner(iouReport) || hasReportBeenRetracted && isReportOwner(iouReport); + const isOwnAndReportHasBeenRetracted = isReportOwner(iouReport) && (hasReportBeenRetracted || hasReportBeenReopened); return isOwnAndReportHasBeenReopened || isWaitingForSubmissionFromCurrentUserReportUtils(chatReport, policy); }, [chatReport, policy, hasReportBeenReopened, hasReportBeenRetracted, iouReport]); From 78729c740baf27975004825e0b56aba2faf87f9c Mon Sep 17 00:00:00 2001 From: BlameGPT <42474517+BlameGPT@users.noreply.github.com> Date: Mon, 28 Jul 2025 15:47:04 +0300 Subject: [PATCH 05/14] Update Report.ts --- src/types/onyx/Report.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/types/onyx/Report.ts b/src/types/onyx/Report.ts index b6ba318ab743..bad6ed407819 100644 --- a/src/types/onyx/Report.ts +++ b/src/types/onyx/Report.ts @@ -194,6 +194,9 @@ type Report = OnyxCommon.OnyxValueWithOfflineFeedback< /** Whether the report is cancelled */ isCancelledIOU?: boolean; + /** Whether the report has been retracted */ + hasReportBeenRetracted?: boolean; + /** The ID of the IOU report */ iouReportID?: string; From 2dc6dc0a5ce2d426909c7623c54cbe0681ef2f09 Mon Sep 17 00:00:00 2001 From: BlameGPT <42474517+BlameGPT@users.noreply.github.com> Date: Mon, 28 Jul 2025 15:47:52 +0300 Subject: [PATCH 06/14] Update whitelistedReportKeys.ts --- src/types/utils/whitelistedReportKeys.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/utils/whitelistedReportKeys.ts b/src/types/utils/whitelistedReportKeys.ts index 847efeb1c7ae..9aebfd3b2596 100644 --- a/src/types/utils/whitelistedReportKeys.ts +++ b/src/types/utils/whitelistedReportKeys.ts @@ -50,6 +50,7 @@ type WhitelistedReport = OnyxCommon.OnyxValueWithOfflineFeedback< errors: unknown; isWaitingOnBankAccount: unknown; isCancelledIOU: unknown; + hasReportBeenRetracted: unknown; iouReportID: unknown; preexistingReportID: unknown; nonReimbursableTotal: unknown; From 3bd9384fe86be63da6277983197b0d209d6b5efd Mon Sep 17 00:00:00 2001 From: BlameGPT <42474517+BlameGPT@users.noreply.github.com> Date: Mon, 28 Jul 2025 15:49:16 +0300 Subject: [PATCH 07/14] Update DebugUtils.ts --- src/libs/DebugUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/DebugUtils.ts b/src/libs/DebugUtils.ts index 410386bccaf8..36f4a5c1cfad 100644 --- a/src/libs/DebugUtils.ts +++ b/src/libs/DebugUtils.ts @@ -471,6 +471,7 @@ function validateReportDraftProperty(key: keyof Report | keyof ReportNameValuePa case 'hasParentAccess': case 'isDeletedParentAction': case 'isWaitingOnBankAccount': + case 'hasReportBeenRetracted': case 'isCancelledIOU': return validateBoolean(value); case 'exportFailedTime': From 193854b81b3d87a8b97de335ace56199e7213c3d Mon Sep 17 00:00:00 2001 From: BlameGPT <42474517+BlameGPT@users.noreply.github.com> Date: Mon, 28 Jul 2025 15:49:50 +0300 Subject: [PATCH 08/14] Update DebugUtils.ts --- src/libs/DebugUtils.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libs/DebugUtils.ts b/src/libs/DebugUtils.ts index 36f4a5c1cfad..8a6c71232991 100644 --- a/src/libs/DebugUtils.ts +++ b/src/libs/DebugUtils.ts @@ -624,6 +624,7 @@ function validateReportDraftProperty(key: keyof Report | keyof ReportNameValuePa unheldNonReimbursableTotal: CONST.RED_BRICK_ROAD_PENDING_ACTION, isWaitingOnBankAccount: CONST.RED_BRICK_ROAD_PENDING_ACTION, isCancelledIOU: CONST.RED_BRICK_ROAD_PENDING_ACTION, + hasReportBeenRetracted: CONST.RED_BRICK_ROAD_PENDING_ACTION, iouReportID: CONST.RED_BRICK_ROAD_PENDING_ACTION, preexistingReportID: CONST.RED_BRICK_ROAD_PENDING_ACTION, nonReimbursableTotal: CONST.RED_BRICK_ROAD_PENDING_ACTION, From 0343bbdd6b2c7ad6e1893e3df152d12fba5e713e Mon Sep 17 00:00:00 2001 From: BlameGPT <42474517+BlameGPT@users.noreply.github.com> Date: Wed, 30 Jul 2025 17:21:34 +0300 Subject: [PATCH 09/14] Update src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx --- .../MoneyRequestReportPreviewContent.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index 96d038a624c5..3ebfa2f434a2 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -192,7 +192,7 @@ function MoneyRequestReportPreviewContent({ // Or if the report has been reopened or retracted const isWaitingForSubmissionFromCurrentUser = useMemo(() => { const isOwnAndReportHasBeenRetracted = isReportOwner(iouReport) && (hasReportBeenRetracted || hasReportBeenReopened); - return isOwnAndReportHasBeenReopened || isWaitingForSubmissionFromCurrentUserReportUtils(chatReport, policy); + return isOwnAndReportHasBeenRetracted || isWaitingForSubmissionFromCurrentUserReportUtils(chatReport, policy); }, [chatReport, policy, hasReportBeenReopened, hasReportBeenRetracted, iouReport]); const confirmPayment = useCallback( From 5cafc47e87db1158e7053d4dae02434dad5e44d1 Mon Sep 17 00:00:00 2001 From: BlameGPT <42474517+BlameGPT@users.noreply.github.com> Date: Thu, 31 Jul 2025 17:36:21 +0300 Subject: [PATCH 10/14] Apply suggestions from code review Co-authored-by: Rushat Gabhane --- .../MoneyRequestReportPreviewContent.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index 1c84e1d8fec0..62a88ee90985 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -185,8 +185,8 @@ function MoneyRequestReportPreviewContent({ const {isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext); const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, {canBeMissing: true}); - const hasReportBeenReopened = report.hasReportBeenReopened ?? false; - const hasReportBeenRetracted = report.hasReportBeenRetracted ?? false; + const hasReportBeenReopened = iouReport?.hasReportBeenReopened ?? false; + const hasReportBeenRetracted = iouReport?.hasReportBeenRetracted ?? false; // The submit button should be success green color only if the user is submitter and the policy does not have Scheduled Submit turned on // Or if the report has been reopened or retracted From de8a9eed452ed31dc3957d123540a31a8610b90c Mon Sep 17 00:00:00 2001 From: BlameGPT <42474517+BlameGPT@users.noreply.github.com> Date: Fri, 8 Aug 2025 15:56:58 +0300 Subject: [PATCH 11/14] fix: show submit button if report has been retracted/ reopened --- .../MoneyRequestReportPreviewContent.tsx | 9 +++++---- src/libs/ReportActionsUtils.ts | 5 +++++ src/libs/ReportPreviewActionUtils.ts | 8 +++++--- src/libs/ReportPrimaryActionUtils.ts | 5 +++-- src/libs/ReportSecondaryActionUtils.ts | 5 +++-- src/libs/ReportUtils.ts | 19 ++++++++++++++++++- 6 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index 70eb3899a3e0..d510f457cc15 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -48,6 +48,8 @@ import { getReportStatusTranslation, getTransactionsWithReceipts, hasHeldExpenses as hasHeldExpensesReportUtils, + hasReportBeenReopened as hasReportBeenReopenedUtils, + hasReportBeenRetracted as hasReportBeenRetractedUtils, hasNonReimbursableTransactions as hasNonReimbursableTransactionsReportUtils, hasOnlyHeldExpenses as hasOnlyHeldExpensesReportUtils, hasOnlyTransactionsWithPendingRoutes as hasOnlyTransactionsWithPendingRoutesReportUtils, @@ -186,15 +188,14 @@ function MoneyRequestReportPreviewContent({ const {isDelegateAccessRestricted, showDelegateNoAccessModal} = useContext(DelegateNoAccessContext); const [reportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${iouReportID}`, {canBeMissing: true}); - const hasReportBeenReopened = iouReport?.hasReportBeenReopened ?? false; - const hasReportBeenRetracted = iouReport?.hasReportBeenRetracted ?? false; + const hasReportBeenRetracted = hasReportBeenReopenedUtils(iouReport, reportActions) || hasReportBeenRetractedUtils(iouReport, reportActions); // The submit button should be success green color only if the user is submitter and the policy does not have Scheduled Submit turned on // Or if the report has been reopened or retracted const isWaitingForSubmissionFromCurrentUser = useMemo(() => { - const isOwnAndReportHasBeenRetracted = isReportOwner(iouReport) && (hasReportBeenRetracted || hasReportBeenReopened); + const isOwnAndReportHasBeenRetracted = isReportOwner(iouReport) && hasReportBeenRetracted; return isOwnAndReportHasBeenRetracted || isWaitingForSubmissionFromCurrentUserReportUtils(chatReport, policy); - }, [chatReport, policy, hasReportBeenReopened, hasReportBeenRetracted, iouReport]); + }, [chatReport, policy, hasReportBeenRetracted, iouReport]); const confirmPayment = useCallback( (type: PaymentMethodType | undefined, payAsBusiness?: boolean) => { diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 6c0827a35e63..2ea06e8a137c 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -372,6 +372,10 @@ function isReopenedAction(reportAction: OnyxEntry): reportAction i return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.REOPENED); } +function isRetractedAction(reportAction: OnyxEntry): reportAction is ReportAction { + return isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.RETRACTED); +} + function isRoomChangeLogAction(reportAction: OnyxEntry): reportAction is ReportAction> { return reportAction?.actionName ? ROOM_CHANGE_LOG_ARRAY.has(reportAction.actionName) : false; } @@ -3139,6 +3143,7 @@ export { getRetractedMessage, getReportActionFromExpensifyCard, isReopenedAction, + isRetractedAction, getIntegrationSyncFailedMessage, getManagerOnVacation, getVacationer, diff --git a/src/libs/ReportPreviewActionUtils.ts b/src/libs/ReportPreviewActionUtils.ts index 7fd5dff4ff67..6da28e2c967b 100644 --- a/src/libs/ReportPreviewActionUtils.ts +++ b/src/libs/ReportPreviewActionUtils.ts @@ -17,6 +17,8 @@ import { getMoneyRequestSpendBreakdown, getParentReport, getReportTransactions, + hasReportBeenReopened as hasReportBeenReopenedUtils, + hasReportBeenRetracted as hasReportBeenRetractedUtils, hasAnyViolations as hasAnyViolationsUtil, hasMissingSmartscanFields, isClosedReport, @@ -45,7 +47,7 @@ function canSubmit(report: Report, violations: OnyxCollection 0 && transactions.every((transaction) => isPending(transaction))) { @@ -63,8 +65,8 @@ function canSubmit(report: Report, violations: OnyxCollection 0; - // If a report has been reopened, we allow submission regardless of the auto reporting frequency. - if (baseCanSubmit && hasBeenReopened) { + // If a report has been retracted, we allow submission regardless of the auto reporting frequency. + if (baseCanSubmit && hasBeenRetracted) { return true; } diff --git a/src/libs/ReportPrimaryActionUtils.ts b/src/libs/ReportPrimaryActionUtils.ts index a36eec096746..d8b0d42549f9 100644 --- a/src/libs/ReportPrimaryActionUtils.ts +++ b/src/libs/ReportPrimaryActionUtils.ts @@ -21,6 +21,7 @@ import { hasExportError as hasExportErrorUtil, hasOnlyHeldExpenses, hasReportBeenReopened as hasReportBeenReopenedUtils, + hasReportBeenRetracted as hasReportBeenRetractedUtils, isArchivedReport, isClosedReport as isClosedReportUtils, isCurrentUserSubmitter, @@ -87,7 +88,7 @@ function isSubmitAction(report: Report, reportTransactions: Transaction[], polic } const isAnyReceiptBeingScanned = reportTransactions?.some((transaction) => isScanning(transaction)); - const hasReportBeenReopened = hasReportBeenReopenedUtils(reportActions); + const hasReportBeenRetracted = hasReportBeenReopenedUtils(report, reportActions) || hasReportBeenRetractedUtils(report, reportActions); if (isAnyReceiptBeingScanned) { return false; @@ -100,7 +101,7 @@ function isSubmitAction(report: Report, reportTransactions: Transaction[], polic } const baseIsSubmit = isExpenseReport && isReportSubmitter && isOpenReport && reportTransactions.length !== 0 && transactionAreComplete; - if (hasReportBeenReopened && baseIsSubmit) { + if (hasReportBeenRetracted && baseIsSubmit) { return true; } diff --git a/src/libs/ReportSecondaryActionUtils.ts b/src/libs/ReportSecondaryActionUtils.ts index a3f428340577..c2b8b376b376 100644 --- a/src/libs/ReportSecondaryActionUtils.ts +++ b/src/libs/ReportSecondaryActionUtils.ts @@ -25,6 +25,7 @@ import { getTransactionDetails, hasOnlyHeldExpenses, hasReportBeenReopened as hasReportBeenReopenedUtils, + hasReportBeenRetracted as hasReportBeenRetractedUtils, isArchivedReport, isAwaitingFirstLevelApproval, isClosedReport as isClosedReportUtils, @@ -164,8 +165,8 @@ function isSubmitAction( return false; } - const hasReportBeenReopened = hasReportBeenReopenedUtils(reportActions); - if (hasReportBeenReopened && isReportSubmitter) { + const hasReportBeenRetracted = hasReportBeenReopenedUtils(report, reportActions) || hasReportBeenRetractedUtils(report, reportActions); + if (hasReportBeenRetracted && isReportSubmitter) { return false; } diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index fd4d3118eb58..9cfc662d3ed6 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -195,6 +195,7 @@ import { isReimbursementQueuedAction, isRenamedAction, isReopenedAction, + isRetractedAction, isReportActionAttachment, isReportPreviewAction, isReversedTransaction, @@ -11263,7 +11264,7 @@ function findReportIDForAction(action?: ReportAction): string | undefined { ?.replace(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}`, ''); } -function hasReportBeenReopened(reportActions: OnyxEntry | ReportAction[], report?: OnyxEntry): boolean { +function hasReportBeenReopened(report: OnyxEntry, reportActions?: OnyxEntry | ReportAction[]): boolean { // If report object is provided and has the property, use it directly if (report?.hasReportBeenReopened !== undefined) { return report.hasReportBeenReopened; @@ -11278,6 +11279,21 @@ function hasReportBeenReopened(reportActions: OnyxEntry | ReportA return reportActionList.some((action) => isReopenedAction(action)); } +function hasReportBeenRetracted(report: OnyxEntry, reportActions?: OnyxEntry | ReportAction[]): boolean { + // If report object is provided and has the property, use it directly + if (report?.hasReportBeenRetracted !== undefined) { + return report.hasReportBeenRetracted; + } + + // Fallback to checking actions for backward compatibility + if (!reportActions) { + return false; + } + + const reportActionList = Array.isArray(reportActions) ? reportActions : Object.values(reportActions); + return reportActionList.some((action) => isRetractedAction(action)); +} + function getMoneyReportPreviewName(action: ReportAction, iouReport: OnyxEntry, isInvoice?: boolean) { if (isInvoice && isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.REPORT_PREVIEW)) { const originalMessage = getOriginalMessage(action); @@ -11704,6 +11720,7 @@ export { pushTransactionViolationsOnyxData, navigateOnDeleteExpense, hasReportBeenReopened, + hasReportBeenRetracted, getMoneyReportPreviewName, getNextApproverAccountID, isWorkspaceTaskReport, From d521abff07ad158ff85a5fc0ccc59a117e842116 Mon Sep 17 00:00:00 2001 From: BlameGPT <42474517+BlameGPT@users.noreply.github.com> Date: Fri, 8 Aug 2025 16:10:07 +0300 Subject: [PATCH 12/14] run pretty --- .../MoneyRequestReportPreviewContent.tsx | 4 ++-- src/libs/ReportPreviewActionUtils.ts | 4 ++-- src/libs/ReportUtils.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx index d510f457cc15..2d3c420e8185 100644 --- a/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx +++ b/src/components/ReportActionItem/MoneyRequestReportPreview/MoneyRequestReportPreviewContent.tsx @@ -48,11 +48,11 @@ import { getReportStatusTranslation, getTransactionsWithReceipts, hasHeldExpenses as hasHeldExpensesReportUtils, - hasReportBeenReopened as hasReportBeenReopenedUtils, - hasReportBeenRetracted as hasReportBeenRetractedUtils, hasNonReimbursableTransactions as hasNonReimbursableTransactionsReportUtils, hasOnlyHeldExpenses as hasOnlyHeldExpensesReportUtils, hasOnlyTransactionsWithPendingRoutes as hasOnlyTransactionsWithPendingRoutesReportUtils, + hasReportBeenReopened as hasReportBeenReopenedUtils, + hasReportBeenRetracted as hasReportBeenRetractedUtils, hasUpdatedTotal, isInvoiceReport as isInvoiceReportUtils, isInvoiceRoom as isInvoiceRoomReportUtils, diff --git a/src/libs/ReportPreviewActionUtils.ts b/src/libs/ReportPreviewActionUtils.ts index 6da28e2c967b..49797eec4548 100644 --- a/src/libs/ReportPreviewActionUtils.ts +++ b/src/libs/ReportPreviewActionUtils.ts @@ -17,10 +17,10 @@ import { getMoneyRequestSpendBreakdown, getParentReport, getReportTransactions, - hasReportBeenReopened as hasReportBeenReopenedUtils, - hasReportBeenRetracted as hasReportBeenRetractedUtils, hasAnyViolations as hasAnyViolationsUtil, hasMissingSmartscanFields, + hasReportBeenReopened as hasReportBeenReopenedUtils, + hasReportBeenRetracted as hasReportBeenRetractedUtils, isClosedReport, isCurrentUserSubmitter, isExpenseReport, diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 9cfc662d3ed6..74614d6a16a5 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -195,9 +195,9 @@ import { isReimbursementQueuedAction, isRenamedAction, isReopenedAction, - isRetractedAction, isReportActionAttachment, isReportPreviewAction, + isRetractedAction, isReversedTransaction, isRoomChangeLogAction, isSentMoneyReportAction, From 1c44ed0249976490e4281419542214db3280ea9d Mon Sep 17 00:00:00 2001 From: BlameGPT <42474517+BlameGPT@users.noreply.github.com> Date: Fri, 8 Aug 2025 16:23:32 +0300 Subject: [PATCH 13/14] fix api err --- src/libs/actions/IOU.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 70f8be6104e3..561966e05216 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -152,6 +152,7 @@ import { hasHeldExpenses as hasHeldExpensesReportUtils, hasNonReimbursableTransactions as hasNonReimbursableTransactionsReportUtils, hasReportBeenReopened, + hasReportBeenRetracted, isArchivedReport, isClosedReport as isClosedReportUtil, isDraftReport, @@ -9481,7 +9482,7 @@ function canSubmitReport( !isReportArchived && transactions.length > 0; const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.reportID}`] ?? []; - const hasBeenReopened = hasReportBeenReopened(reportActions); + const hasBeenRetracted = hasReportBeenReopened(report, reportActions) || hasReportBeenRetracted(report, reportActions); if (baseCanSubmit && hasBeenReopened) { return true; } From 261c58255bc6648639cdc48d1ad5474a7dd27467 Mon Sep 17 00:00:00 2001 From: BlameGPT <42474517+BlameGPT@users.noreply.github.com> Date: Fri, 8 Aug 2025 16:23:50 +0300 Subject: [PATCH 14/14] fix typo --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 561966e05216..6f6e21fbd2a9 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -9483,7 +9483,7 @@ function canSubmitReport( transactions.length > 0; const reportActions = allReportActions?.[`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${report?.reportID}`] ?? []; const hasBeenRetracted = hasReportBeenReopened(report, reportActions) || hasReportBeenRetracted(report, reportActions); - if (baseCanSubmit && hasBeenReopened) { + if (baseCanSubmit && hasBeenRetracted) { return true; }