From 65d478d59d836918120444550eeaf424d6643303 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Tue, 24 Jun 2025 21:44:07 +0300 Subject: [PATCH 1/2] update lastVisibleActionCreated on create report --- src/libs/actions/Report.ts | 11 +++++++++++ tests/actions/ReportTest.ts | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 1d432ad405ae..ec7b7f2e66a5 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2732,6 +2732,11 @@ function buildNewReportOptimisticData(policy: OnyxEntry, reportID: strin key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReport?.reportID}`, value: {[reportPreviewReportActionID]: optimisticReportPreview}, }, + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${parentReport?.reportID}`, + value: {lastVisibleActionCreated: optimisticReportPreview.created}, + }, { onyxMethod: Onyx.METHOD.SET, key: `${ONYXKEYS.COLLECTION.NEXT_STEP}${reportID}`, @@ -2764,6 +2769,12 @@ function buildNewReportOptimisticData(policy: OnyxEntry, reportID: strin key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, value: quickAction ?? null, }, + + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${parentReport?.reportID}`, + value: {lastVisibleActionCreated: parentReport?.lastVisibleActionCreated}, + }, ]; const successData: OnyxUpdate[] = [ diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index 74e7e5d87cd7..0ffdb1f8634d 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -1552,9 +1552,11 @@ describe('actions/Report', () => { callback: (reports) => { Onyx.disconnect(connection); const createdReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; + const parentPolicyExpenseChat = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${parentReport?.reportID}`]; // assert correctness of crucial onyx data expect(createdReport?.reportID).toBe(reportID); + expect(parentPolicyExpenseChat?.lastVisibleActionCreated).toBe(reportPreviewAction?.created); expect(createdReport?.total).toBe(0); expect(createdReport?.parentReportActionID).toBe(reportPreviewAction?.reportActionID); From 645f6a41ea58dd996dc87c84d997701f4ea6d825 Mon Sep 17 00:00:00 2001 From: FitseTLT Date: Wed, 25 Jun 2025 21:20:10 +0300 Subject: [PATCH 2/2] added back test --- tests/actions/ReportTest.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index 8c784bd3cc5e..c76d75abae75 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -1558,9 +1558,10 @@ describe('actions/Report', () => { // callback: (reports) => { // Onyx.disconnect(connection); // const createdReport = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${reportID}`]; - +// const parentPolicyExpenseChat = reports?.[`${ONYXKEYS.COLLECTION.REPORT}${parentReport?.reportID}`]; // // assert correctness of crucial onyx data // expect(createdReport?.reportID).toBe(reportID); +// expect(parentPolicyExpenseChat?.lastVisibleActionCreated).toBe(reportPreviewAction?.created); // expect(createdReport?.total).toBe(0); // expect(createdReport?.parentReportActionID).toBe(reportPreviewAction?.reportActionID);