diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index dcc5ad7a0d623..31f112104f8eb 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -9874,7 +9874,7 @@ function prepareOnboardingOnyxData( onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, value: { - [taskReportAction.reportAction.reportActionID]: {pendingAction: null}, + [taskReportAction.reportAction.reportActionID]: {pendingAction: null, isOptimisticAction: null}, }, }, { @@ -9910,7 +9910,7 @@ function prepareOnboardingOnyxData( onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${currentTask.reportID}`, value: { - [completedTaskReportAction.reportActionID]: {pendingAction: null}, + [completedTaskReportAction.reportActionID]: {pendingAction: null, isOptimisticAction: null}, }, }); } @@ -9968,7 +9968,7 @@ function prepareOnboardingOnyxData( onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, value: { - [textCommentAction.reportActionID]: {pendingAction: null}, + [textCommentAction.reportActionID]: {pendingAction: null, isOptimisticAction: null}, }, }); } @@ -10156,7 +10156,7 @@ function prepareOnboardingOnyxData( onyxMethod: Onyx.METHOD.MERGE, key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${targetChatReportID}`, value: { - [welcomeSignOffCommentAction.reportActionID]: {pendingAction: null}, + [welcomeSignOffCommentAction.reportActionID]: {pendingAction: null, isOptimisticAction: null}, }, }); diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index e7c4271c14888..c5ffd3b12eaa2 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -68,6 +68,7 @@ describe('actions/Report', () => { beforeEach(() => { HttpUtils.xhr = originalXHR; const promise = Onyx.clear().then(jest.useRealTimers); + if (getIsUsingFakeTimers()) { // flushing pending timers // Onyx.clear() promise is resolved in batch which happens after the current microtasks cycle @@ -1606,4 +1607,45 @@ describe('actions/Report', () => { expect(derivedConciergeChatReportID).toBe(conciergeChatReport2.reportID); }); }); + + describe('completeOnboarding', () => { + const TEST_USER_LOGIN = 'test@gmail.com'; + const TEST_USER_ACCOUNT_ID = 1; + global.fetch = TestHelper.getGlobalFetchMock(); + + it('should set "isOptimisticAction" to false/null for all actions in admins report after completing onboarding setup', async () => { + await Onyx.set(ONYXKEYS.SESSION, {email: TEST_USER_LOGIN, accountID: TEST_USER_ACCOUNT_ID}); + await waitForBatchedUpdates(); + + const adminsChatReportID = '7957055873634067'; + const onboardingPolicyID = 'A70D00C752416807'; + const engagementChoice = CONST.INTRO_CHOICES.MANAGE_TEAM; + + Report.completeOnboarding({ + engagementChoice, + onboardingMessage: CONST.ONBOARDING_MESSAGES[engagementChoice], + adminsChatReportID, + onboardingPolicyID, + companySize: CONST.ONBOARDING_COMPANY_SIZE.MICRO, + userReportedIntegration: null, + }); + + await waitForBatchedUpdates(); + + const reportActions: OnyxEntry = await new Promise((resolve) => { + const connection = Onyx.connect({ + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${adminsChatReportID}`, + callback: (id) => { + Onyx.disconnect(connection); + resolve(id); + }, + }); + }); + expect(reportActions).not.toBeNull(); + expect(reportActions).not.toBeUndefined(); + Object.values(reportActions ?? {}).forEach((action) => { + expect(action.isOptimisticAction).toBeFalsy(); + }); + }); + }); });