From 1f43e66de9bdef092bad7c7af7559b9af23be279 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 17 Dec 2025 00:14:26 +0300 Subject: [PATCH 1/3] set empty report to draft status for instant submit with approval disabled --- src/libs/ReportUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 044131608b6e..e6b50f7ebbec 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6865,7 +6865,7 @@ function getExpenseReportStateAndStatus(policy: OnyxEntry, isEmptyOptimi }; } - if (isInstantSubmitEnabledLocal) { + if (isInstantSubmitEnabledLocal && !(isSubmitAndCloseLocal && isEmptyOptimisticReport)) { return { stateNum: CONST.REPORT.STATE_NUM.SUBMITTED, statusNum: CONST.REPORT.STATUS_NUM.SUBMITTED, From 2c8e2b5ab6914acb995913922d6baf7cfe57f767 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Thu, 18 Dec 2025 16:10:35 +0300 Subject: [PATCH 2/3] added test --- tests/actions/ReportTest.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index 2e8f0aae252f..6df1daf437f8 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -1890,6 +1890,42 @@ describe('actions/Report', () => { }); }); + it('should create the empty report with draft status if submission is instant with approval disabled', async () => { + const accountID = 1234; + const policyID = '5678'; + // Given a policy with instant submission and approval disabled + const policy: OnyxTypes.Policy = { + ...createRandomPolicy(Number(policyID)), + isPolicyExpenseChatEnabled: true, + type: CONST.POLICY.TYPE.TEAM, + autoReportingFrequency: CONST.POLICY.AUTO_REPORTING_FREQUENCIES.INSTANT, + approvalMode: CONST.POLICY.APPROVAL_MODE.OPTIONAL, + }; + const parentReport = ReportUtils.getPolicyExpenseChat(accountID, policyID); + await Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, policy); + if (parentReport?.reportID) { + await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${parentReport?.reportID}`, parentReport); + } + + // When create new report + const optimisticReportData = Report.createNewReport({accountID}, true, false, policyID); + + await waitForBatchedUpdates(); + // Then the report's status should be draft. + await new Promise((resolve) => { + const connection = Onyx.connect({ + key: `${ONYXKEYS.COLLECTION.REPORT}${optimisticReportData.reportID}`, + callback: (report) => { + Onyx.disconnect(connection); + expect(report?.stateNum).toBe(CONST.REPORT.STATE_NUM.OPEN); + expect(report?.statusNum).toBe(CONST.REPORT.STATUS_NUM.OPEN); + + resolve(); + }, + }); + }); + }); + describe('completeOnboarding', () => { const TEST_USER_LOGIN = 'test@gmail.com'; const TEST_USER_ACCOUNT_ID = 1; From d1170c7febb052885f1c891828fc8b54bd2104eb Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Mon, 12 Jan 2026 18:52:53 +0300 Subject: [PATCH 3/3] fix lint --- tests/actions/ReportTest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index 04c92a4070d1..e43e12e1ceb5 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -1987,7 +1987,7 @@ describe('actions/Report', () => { } // When create new report - const optimisticReportData = Report.createNewReport({accountID}, true, false, policyID); + const optimisticReportData = Report.createNewReport({accountID}, true, false, policy); await waitForBatchedUpdates(); // Then the report's status should be draft.