From 85fefb0818ef8dd514232c744026892f188c6cbe Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 19 Mar 2026 02:22:49 +0530 Subject: [PATCH 1/3] Part 9 - Thread betas through navigateToAndOpenChildReport and toggleSubscribeToChildReport Signed-off-by: krishna2323 --- src/libs/actions/Report/index.ts | 9 ++++-- .../report/ContextMenu/ContextMenuActions.tsx | 18 ++++++------ .../inbox/report/ReportActionItemThread.tsx | 3 +- tests/actions/ReportTest.ts | 28 ++++++++++++------- 4 files changed, 36 insertions(+), 22 deletions(-) diff --git a/src/libs/actions/Report/index.ts b/src/libs/actions/Report/index.ts index aaa3f7d833034..45bbfd4722d73 100644 --- a/src/libs/actions/Report/index.ts +++ b/src/libs/actions/Report/index.ts @@ -2097,8 +2097,9 @@ function navigateToAndOpenChildReport( parentReport: OnyxEntry, currentUserAccountID: number, introSelected: OnyxEntry, + betas: OnyxEntry, ) { - const report = childReport ?? createChildReport(childReport, parentReportAction, parentReport, currentUserAccountID, introSelected); + const report = childReport ?? createChildReport(childReport, parentReportAction, parentReport, currentUserAccountID, introSelected, betas); Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.reportID, undefined, undefined, Navigation.getActiveRoute())); } @@ -2114,6 +2115,7 @@ function createChildReport( parentReport: OnyxEntry, currentUserAccountID: number, introSelected: OnyxEntry, + betas: OnyxEntry, ): Report { const participantAccountIDs = [...new Set([currentUserAccountID, Number(parentReportAction.actorAccountID)])]; // Threads from DMs and selfDMs don't have a chatType. All other threads inherit the chatType from their parent @@ -2141,6 +2143,7 @@ function createChildReport( newReportObject: newChat, parentReportActionID: parentReportAction.reportActionID, isNewThread: true, + betas, }); } else { Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${childReportID}`, newChat); @@ -2947,10 +2950,11 @@ function toggleSubscribeToChildReport( parentReportAction: ReportAction, parentReport: OnyxEntry, introSelected: OnyxEntry, + betas: OnyxEntry, prevNotificationPreference?: NotificationPreference, ) { if (childReportID) { - openReport({reportID: childReportID, introSelected}); + openReport({reportID: childReportID, introSelected, betas}); const parentReportActionID = parentReportAction.reportActionID; if (!prevNotificationPreference || isHiddenForCurrentUser(prevNotificationPreference)) { updateNotificationPreference( @@ -2991,6 +2995,7 @@ function toggleSubscribeToChildReport( participantLoginList: participantLogins, newReportObject: newChat, parentReportActionID: parentReportAction.reportActionID, + betas, }); const notificationPreference = isHiddenForCurrentUser(prevNotificationPreference) ? CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS : CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN; updateNotificationPreference(newChat.reportID, prevNotificationPreference, notificationPreference, currentUserAccountID, parentReport?.reportID, parentReportAction.reportActionID); diff --git a/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx b/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx index 57609718b9247..714521b9bb550 100644 --- a/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx @@ -428,16 +428,16 @@ const ContextMenuActions: ContextMenuAction[] = [ } return !shouldDisableThread(reportAction, isThreadReportParentAction, isArchivedRoom); }, - onPress: (closePopover, {reportAction, childReport, originalReport, currentUserAccountID, introSelected}) => { + onPress: (closePopover, {reportAction, childReport, originalReport, currentUserAccountID, introSelected, betas}) => { if (closePopover) { hideContextMenu(false, () => { KeyboardUtils.dismiss().then(() => { - navigateToAndOpenChildReport(childReport, reportAction, originalReport, currentUserAccountID, introSelected); + navigateToAndOpenChildReport(childReport, reportAction, originalReport, currentUserAccountID, introSelected, betas); }); }); return; } - navigateToAndOpenChildReport(childReport, reportAction, originalReport, currentUserAccountID, introSelected); + navigateToAndOpenChildReport(childReport, reportAction, originalReport, currentUserAccountID, introSelected, betas); }, getDescription: () => {}, sentryLabel: CONST.SENTRY_LABEL.CONTEXT_MENU.REPLY_IN_THREAD, @@ -626,18 +626,18 @@ const ContextMenuActions: ContextMenuAction[] = [ (shouldDisplayThreadReplies || (!isDeletedAction && !isArchivedRoom)) ); }, - onPress: (closePopover, {reportAction, currentUserAccountID, originalReport, introSelected}) => { + onPress: (closePopover, {reportAction, currentUserAccountID, originalReport, introSelected, betas}) => { const childReportNotificationPreference = getChildReportNotificationPreferenceReportUtils(reportAction); if (closePopover) { hideContextMenu(false, () => { ReportActionComposeFocusManager.focus(); - toggleSubscribeToChildReport(reportAction?.childReportID, currentUserAccountID, reportAction, originalReport, introSelected, childReportNotificationPreference); + toggleSubscribeToChildReport(reportAction?.childReportID, currentUserAccountID, reportAction, originalReport, introSelected, betas, childReportNotificationPreference); }); return; } ReportActionComposeFocusManager.focus(); - toggleSubscribeToChildReport(reportAction?.childReportID, currentUserAccountID, reportAction, originalReport, introSelected, childReportNotificationPreference); + toggleSubscribeToChildReport(reportAction?.childReportID, currentUserAccountID, reportAction, originalReport, introSelected, betas, childReportNotificationPreference); }, getDescription: () => {}, sentryLabel: CONST.SENTRY_LABEL.CONTEXT_MENU.JOIN_THREAD, @@ -665,18 +665,18 @@ const ContextMenuActions: ContextMenuAction[] = [ (shouldDisplayThreadReplies || (!isDeletedAction && !isArchivedRoom)) ); }, - onPress: (closePopover, {reportAction, currentUserAccountID, originalReport, introSelected}) => { + onPress: (closePopover, {reportAction, currentUserAccountID, originalReport, introSelected, betas}) => { const childReportNotificationPreference = getChildReportNotificationPreferenceReportUtils(reportAction); if (closePopover) { hideContextMenu(false, () => { ReportActionComposeFocusManager.focus(); - toggleSubscribeToChildReport(reportAction?.childReportID, currentUserAccountID, reportAction, originalReport, introSelected, childReportNotificationPreference); + toggleSubscribeToChildReport(reportAction?.childReportID, currentUserAccountID, reportAction, originalReport, introSelected, betas, childReportNotificationPreference); }); return; } ReportActionComposeFocusManager.focus(); - toggleSubscribeToChildReport(reportAction?.childReportID, currentUserAccountID, reportAction, originalReport, introSelected, childReportNotificationPreference); + toggleSubscribeToChildReport(reportAction?.childReportID, currentUserAccountID, reportAction, originalReport, introSelected, betas, childReportNotificationPreference); }, getDescription: () => {}, sentryLabel: CONST.SENTRY_LABEL.CONTEXT_MENU.LEAVE_THREAD, diff --git a/src/pages/inbox/report/ReportActionItemThread.tsx b/src/pages/inbox/report/ReportActionItemThread.tsx index 81f50e8f7c2a9..5c8568cf4eddc 100644 --- a/src/pages/inbox/report/ReportActionItemThread.tsx +++ b/src/pages/inbox/report/ReportActionItemThread.tsx @@ -58,6 +58,7 @@ function ReportActionItemThread({ const {translate, datetimeToCalendarTime} = useLocalize(); const [childReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportAction.childReportID}`); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); + const [betas] = useOnyx(ONYXKEYS.BETAS); const numberOfRepliesText = numberOfReplies > CONST.MAX_THREAD_REPLIES_PREVIEW ? `${CONST.MAX_THREAD_REPLIES_PREVIEW}+` : `${numberOfReplies}`; const replyText = numberOfReplies === 1 ? translate('threads.reply') : translate('threads.replies'); @@ -68,7 +69,7 @@ function ReportActionItemThread({ { - navigateToAndOpenChildReport(childReport, reportAction, report, currentUserAccountID, introSelected); + navigateToAndOpenChildReport(childReport, reportAction, report, currentUserAccountID, introSelected, betas); }} role={CONST.ROLE.BUTTON} accessibilityLabel={`${numberOfReplies} ${replyText}`} diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index b6451e05d7abc..965b079a8d2d2 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -4230,7 +4230,7 @@ describe('actions/Report', () => { Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${PARENT_REPORT_ID}`, PARENT_REPORT); await waitForBatchedUpdates(); - Report.navigateToAndOpenChildReport(EXISTING_CHILD_REPORT, PARENT_REPORT_ACTION, PARENT_REPORT, TEST_USER_ACCOUNT_ID, INTRO_SELECTED); + Report.navigateToAndOpenChildReport(EXISTING_CHILD_REPORT, PARENT_REPORT_ACTION, PARENT_REPORT, TEST_USER_ACCOUNT_ID, INTRO_SELECTED, undefined); await waitForBatchedUpdates(); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(EXISTING_CHILD_REPORT.reportID)); @@ -4249,7 +4249,7 @@ describe('actions/Report', () => { Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${PARENT_REPORT_ID}`, PARENT_REPORT); await waitForBatchedUpdates(); - Report.navigateToAndOpenChildReport(undefined, PARENT_REPORT_ACTION, PARENT_REPORT, TEST_USER_ACCOUNT_ID, INTRO_SELECTED); + Report.navigateToAndOpenChildReport(undefined, PARENT_REPORT_ACTION, PARENT_REPORT, TEST_USER_ACCOUNT_ID, INTRO_SELECTED, undefined); await waitForBatchedUpdates(); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(MOCK_NEW_THREAD_REPORT_ID)); @@ -4264,7 +4264,7 @@ describe('actions/Report', () => { Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${PARENT_REPORT_ID}`, PARENT_REPORT); await waitForBatchedUpdates(); - Report.navigateToAndOpenChildReport(EXISTING_CHILD_REPORT, {} as OnyxTypes.ReportAction, PARENT_REPORT, TEST_USER_ACCOUNT_ID, INTRO_SELECTED); + Report.navigateToAndOpenChildReport(EXISTING_CHILD_REPORT, {} as OnyxTypes.ReportAction, PARENT_REPORT, TEST_USER_ACCOUNT_ID, INTRO_SELECTED, undefined); await waitForBatchedUpdates(); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(EXISTING_CHILD_REPORT.reportID)); @@ -4283,7 +4283,7 @@ describe('actions/Report', () => { Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${PARENT_REPORT_ID}`, PARENT_REPORT); await waitForBatchedUpdates(); - Report.navigateToAndOpenChildReport(undefined, PARENT_REPORT_ACTION, PARENT_REPORT, TEST_USER_ACCOUNT_ID, INTRO_SELECTED); + Report.navigateToAndOpenChildReport(undefined, PARENT_REPORT_ACTION, PARENT_REPORT, TEST_USER_ACCOUNT_ID, INTRO_SELECTED, undefined); await waitForBatchedUpdates(); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(MOCK_NEW_THREAD_REPORT_ID)); @@ -4302,7 +4302,7 @@ describe('actions/Report', () => { Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${PARENT_REPORT_ID}`, PARENT_REPORT); await waitForBatchedUpdates(); - Report.navigateToAndOpenChildReport(undefined, PARENT_REPORT_ACTION, PARENT_REPORT, TEST_USER_ACCOUNT_ID, INTRO_SELECTED); + Report.navigateToAndOpenChildReport(undefined, PARENT_REPORT_ACTION, PARENT_REPORT, TEST_USER_ACCOUNT_ID, INTRO_SELECTED, undefined); await waitForBatchedUpdates(); // Verify navigation happened with the new thread report @@ -4327,7 +4327,7 @@ describe('actions/Report', () => { Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${PARENT_REPORT_ID}`, PARENT_REPORT); await waitForBatchedUpdates(); - Report.navigateToAndOpenChildReport(EXISTING_CHILD_REPORT, PARENT_REPORT_ACTION, PARENT_REPORT, TEST_USER_ACCOUNT_ID, undefined); + Report.navigateToAndOpenChildReport(EXISTING_CHILD_REPORT, PARENT_REPORT_ACTION, PARENT_REPORT, TEST_USER_ACCOUNT_ID, undefined, undefined); await waitForBatchedUpdates(); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(EXISTING_CHILD_REPORT.reportID)); @@ -4478,7 +4478,7 @@ describe('actions/Report', () => { await waitForBatchedUpdates(); expect(() => { - Report.toggleSubscribeToChildReport(CHILD_REPORT_ID, TEST_USER_ACCOUNT_ID, PARENT_REPORT_ACTION, PARENT_REPORT, INTRO_SELECTED, 'hidden'); + Report.toggleSubscribeToChildReport(CHILD_REPORT_ID, TEST_USER_ACCOUNT_ID, PARENT_REPORT_ACTION, PARENT_REPORT, INTRO_SELECTED, undefined, 'hidden'); }).not.toThrow(); }); @@ -4496,7 +4496,7 @@ describe('actions/Report', () => { await waitForBatchedUpdates(); expect(() => { - Report.toggleSubscribeToChildReport(undefined, TEST_USER_ACCOUNT_ID, PARENT_REPORT_ACTION, PARENT_REPORT, INTRO_SELECTED); + Report.toggleSubscribeToChildReport(undefined, TEST_USER_ACCOUNT_ID, PARENT_REPORT_ACTION, PARENT_REPORT, INTRO_SELECTED, undefined); }).not.toThrow(); }); @@ -4514,7 +4514,7 @@ describe('actions/Report', () => { await waitForBatchedUpdates(); expect(() => { - Report.toggleSubscribeToChildReport(CHILD_REPORT_ID, TEST_USER_ACCOUNT_ID, PARENT_REPORT_ACTION, PARENT_REPORT, undefined, 'hidden'); + Report.toggleSubscribeToChildReport(CHILD_REPORT_ID, TEST_USER_ACCOUNT_ID, PARENT_REPORT_ACTION, PARENT_REPORT, undefined, undefined, 'hidden'); }).not.toThrow(); }); @@ -4532,7 +4532,15 @@ describe('actions/Report', () => { await waitForBatchedUpdates(); expect(() => { - Report.toggleSubscribeToChildReport(CHILD_REPORT_ID, TEST_USER_ACCOUNT_ID, PARENT_REPORT_ACTION, PARENT_REPORT, INTRO_SELECTED, CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS); + Report.toggleSubscribeToChildReport( + CHILD_REPORT_ID, + TEST_USER_ACCOUNT_ID, + PARENT_REPORT_ACTION, + PARENT_REPORT, + INTRO_SELECTED, + undefined, + CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, + ); }).not.toThrow(); }); }); From c7acf0afd5921c814c3de7c061c30d714d52a417 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 19 Mar 2026 03:03:57 +0530 Subject: [PATCH 2/3] Fix missing betas parameter in explain function Signed-off-by: krishna2323 --- src/libs/actions/Report/index.ts | 3 ++- .../inbox/report/ContextMenu/ContextMenuActions.tsx | 6 +++--- .../report/ReportActionItemMessageWithExplain.tsx | 3 ++- tests/actions/ReportTest.ts | 12 ++++++------ 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/libs/actions/Report/index.ts b/src/libs/actions/Report/index.ts index 45bbfd4722d73..927ce125dc5b3 100644 --- a/src/libs/actions/Report/index.ts +++ b/src/libs/actions/Report/index.ts @@ -2163,6 +2163,7 @@ function explain( translate: LocalizedTranslate, currentUserAccountID: number, introSelected: OnyxEntry, + betas: OnyxEntry, timezone: Timezone = CONST.DEFAULT_TIME_ZONE, ) { if (!originalReport?.reportID || !reportAction) { @@ -2170,7 +2171,7 @@ function explain( } // Check if explanation thread report already exists - const report = childReport ?? createChildReport(childReport, reportAction, originalReport, currentUserAccountID, introSelected); + const report = childReport ?? createChildReport(childReport, reportAction, originalReport, currentUserAccountID, introSelected, betas); Navigation.navigate(ROUTES.REPORT_WITH_ID.getRoute(report.reportID, undefined, undefined, Navigation.getActiveRoute())); // Schedule adding the explanation comment on the next animation frame diff --git a/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx b/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx index 714521b9bb550..bafa378f957aa 100644 --- a/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx @@ -471,7 +471,7 @@ const ContextMenuActions: ContextMenuAction[] = [ return hasReasoning(reportAction); }, - onPress: (closePopover, {reportAction, childReport, originalReport, translate, currentUserPersonalDetails, introSelected}) => { + onPress: (closePopover, {reportAction, childReport, originalReport, translate, currentUserPersonalDetails, introSelected, betas}) => { if (!originalReport?.reportID) { return; } @@ -479,13 +479,13 @@ const ContextMenuActions: ContextMenuAction[] = [ if (closePopover) { hideContextMenu(false, () => { KeyboardUtils.dismiss().then(() => { - explain(childReport, originalReport, reportAction, translate, currentUserPersonalDetails.accountID, introSelected, currentUserPersonalDetails?.timezone); + explain(childReport, originalReport, reportAction, translate, currentUserPersonalDetails.accountID, introSelected, betas, currentUserPersonalDetails?.timezone); }); }); return; } - explain(childReport, originalReport, reportAction, translate, currentUserPersonalDetails.accountID, introSelected, currentUserPersonalDetails?.timezone); + explain(childReport, originalReport, reportAction, translate, currentUserPersonalDetails.accountID, introSelected, betas, currentUserPersonalDetails?.timezone); }, getDescription: () => {}, sentryLabel: CONST.SENTRY_LABEL.CONTEXT_MENU.EXPLAIN, diff --git a/src/pages/inbox/report/ReportActionItemMessageWithExplain.tsx b/src/pages/inbox/report/ReportActionItemMessageWithExplain.tsx index 94d69478e209a..a4fc3d19f6b5c 100644 --- a/src/pages/inbox/report/ReportActionItemMessageWithExplain.tsx +++ b/src/pages/inbox/report/ReportActionItemMessageWithExplain.tsx @@ -37,6 +37,7 @@ function ReportActionItemMessageWithExplain({message, action, childReport, origi const personalDetail = useCurrentUserPersonalDetails(); const {environmentURL} = useEnvironment(); const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED); + const [betas] = useOnyx(ONYXKEYS.BETAS); const actionHasReasoning = hasReasoning(action); const computedMessage = actionHasReasoning ? `${message}${translate('iou.AskToExplain')}` : message; @@ -44,7 +45,7 @@ function ReportActionItemMessageWithExplain({message, action, childReport, origi const handleLinkPress = (event: GestureResponderEvent | KeyboardEvent, href: string) => { // Handle the special "Explain" link if (href.endsWith(CONST.CONCIERGE_EXPLAIN_LINK_PATH)) { - explain(childReport, originalReport, action, translate, personalDetail.accountID, introSelected, personalDetail?.timezone); + explain(childReport, originalReport, action, translate, personalDetail.accountID, introSelected, betas, personalDetail?.timezone); return; } diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index 965b079a8d2d2..7a23b693bed53 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -4361,13 +4361,13 @@ describe('actions/Report', () => { actorAccountID: TEST_USER_ACCOUNT_ID, }; - const result = Report.explain(undefined, undefined, REPORT_ACTION, TestHelper.translateLocal, TEST_USER_ACCOUNT_ID, INTRO_SELECTED, CONST.DEFAULT_TIME_ZONE); + const result = Report.explain(undefined, undefined, REPORT_ACTION, TestHelper.translateLocal, TEST_USER_ACCOUNT_ID, INTRO_SELECTED, undefined, CONST.DEFAULT_TIME_ZONE); expect(result).toBeUndefined(); }); it('should return early if reportAction is not provided', () => { - const result = Report.explain(undefined, undefined, undefined, TestHelper.translateLocal, TEST_USER_ACCOUNT_ID, INTRO_SELECTED, CONST.DEFAULT_TIME_ZONE); + const result = Report.explain(undefined, undefined, undefined, TestHelper.translateLocal, TEST_USER_ACCOUNT_ID, INTRO_SELECTED, undefined, CONST.DEFAULT_TIME_ZONE); expect(result).toBeUndefined(); }); @@ -4386,7 +4386,7 @@ describe('actions/Report', () => { Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${CHILD_REPORT_ID}`, EXISTING_CHILD_REPORT); await waitForBatchedUpdates(); - Report.explain(EXISTING_CHILD_REPORT, PARENT_REPORT, REPORT_ACTION, TestHelper.translateLocal, TEST_USER_ACCOUNT_ID, INTRO_SELECTED, CONST.DEFAULT_TIME_ZONE); + Report.explain(EXISTING_CHILD_REPORT, PARENT_REPORT, REPORT_ACTION, TestHelper.translateLocal, TEST_USER_ACCOUNT_ID, INTRO_SELECTED, undefined, CONST.DEFAULT_TIME_ZONE); await waitForBatchedUpdates(); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(EXISTING_CHILD_REPORT.reportID)); @@ -4405,7 +4405,7 @@ describe('actions/Report', () => { Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${PARENT_REPORT_ID}`, PARENT_REPORT); await waitForBatchedUpdates(); - Report.explain(undefined, PARENT_REPORT, REPORT_ACTION, TestHelper.translateLocal, TEST_USER_ACCOUNT_ID, INTRO_SELECTED, CONST.DEFAULT_TIME_ZONE); + Report.explain(undefined, PARENT_REPORT, REPORT_ACTION, TestHelper.translateLocal, TEST_USER_ACCOUNT_ID, INTRO_SELECTED, undefined, CONST.DEFAULT_TIME_ZONE); await waitForBatchedUpdates(); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(MOCK_NEW_THREAD_REPORT_ID)); @@ -4429,7 +4429,7 @@ describe('actions/Report', () => { Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${CHILD_REPORT_ID}`, EXISTING_CHILD_REPORT); await waitForBatchedUpdates(); - Report.explain(EXISTING_CHILD_REPORT, PARENT_REPORT, REPORT_ACTION, TestHelper.translateLocal, TEST_USER_ACCOUNT_ID, INTRO_SELECTED); + Report.explain(EXISTING_CHILD_REPORT, PARENT_REPORT, REPORT_ACTION, TestHelper.translateLocal, TEST_USER_ACCOUNT_ID, INTRO_SELECTED, undefined); await waitForBatchedUpdates(); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(EXISTING_CHILD_REPORT.reportID)); @@ -4449,7 +4449,7 @@ describe('actions/Report', () => { Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${CHILD_REPORT_ID}`, EXISTING_CHILD_REPORT); await waitForBatchedUpdates(); - Report.explain(EXISTING_CHILD_REPORT, PARENT_REPORT, REPORT_ACTION, TestHelper.translateLocal, TEST_USER_ACCOUNT_ID, undefined, CONST.DEFAULT_TIME_ZONE); + Report.explain(EXISTING_CHILD_REPORT, PARENT_REPORT, REPORT_ACTION, TestHelper.translateLocal, TEST_USER_ACCOUNT_ID, undefined, undefined, CONST.DEFAULT_TIME_ZONE); await waitForBatchedUpdates(); expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(EXISTING_CHILD_REPORT.reportID)); From 271822d2bab150b44d54dfb7f25ad63389683217 Mon Sep 17 00:00:00 2001 From: krishna2323 Date: Thu, 19 Mar 2026 15:29:43 +0530 Subject: [PATCH 3/3] add tests. Signed-off-by: krishna2323 --- tests/actions/ReportTest.ts | 80 +++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index 7a23b693bed53..ca4f978bfc2b2 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -4332,6 +4332,27 @@ describe('actions/Report', () => { expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(EXISTING_CHILD_REPORT.reportID)); }); + + it('should pass betas through to openReport when creating a new child report', async () => { + const PARENT_REPORT = createRandomReport(1, undefined); + const PARENT_REPORT_ACTION: OnyxTypes.ReportAction = { + ...createRandomReportAction(REPORT_ACTION_ID), + reportActionID: '1', + actorAccountID: TEST_USER_ACCOUNT_ID, + }; + const testBetas = [CONST.BETAS.ALL]; + + await TestHelper.signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN); + await TestHelper.setPersonalDetails(TEST_USER_LOGIN, TEST_USER_ACCOUNT_ID); + Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${PARENT_REPORT_ID}`, PARENT_REPORT); + await waitForBatchedUpdates(); + + Report.navigateToAndOpenChildReport(undefined, PARENT_REPORT_ACTION, PARENT_REPORT, TEST_USER_ACCOUNT_ID, INTRO_SELECTED, testBetas); + await waitForBatchedUpdates(); + + TestHelper.expectAPICommandToHaveBeenCalled(WRITE_COMMANDS.OPEN_REPORT, 1); + expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(MOCK_NEW_THREAD_REPORT_ID)); + }); }); describe('explain', () => { @@ -4454,6 +4475,27 @@ describe('actions/Report', () => { expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(EXISTING_CHILD_REPORT.reportID)); }); + + it('should pass betas through to createChildReport when creating a new explain thread', async () => { + const PARENT_REPORT = createRandomReport(1, undefined); + const REPORT_ACTION: OnyxTypes.ReportAction = { + ...createRandomReportAction(REPORT_ACTION_ID), + reportActionID: '1', + actorAccountID: TEST_USER_ACCOUNT_ID, + }; + const testBetas = [CONST.BETAS.ALL]; + + await TestHelper.signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN); + await TestHelper.setPersonalDetails(TEST_USER_LOGIN, TEST_USER_ACCOUNT_ID); + Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${PARENT_REPORT_ID}`, PARENT_REPORT); + await waitForBatchedUpdates(); + + Report.explain(undefined, PARENT_REPORT, REPORT_ACTION, TestHelper.translateLocal, TEST_USER_ACCOUNT_ID, INTRO_SELECTED, testBetas, CONST.DEFAULT_TIME_ZONE); + await waitForBatchedUpdates(); + + TestHelper.expectAPICommandToHaveBeenCalled(WRITE_COMMANDS.OPEN_REPORT, 1); + expect(Navigation.navigate).toHaveBeenCalledWith(ROUTES.REPORT_WITH_ID.getRoute(MOCK_NEW_THREAD_REPORT_ID)); + }); }); describe('toggleSubscribeToChildReport', () => { @@ -4543,6 +4585,44 @@ describe('actions/Report', () => { ); }).not.toThrow(); }); + + it('should pass betas to openReport when subscribing to an existing child report', async () => { + const PARENT_REPORT = createRandomReport(Number(PARENT_REPORT_ID), undefined); + const PARENT_REPORT_ACTION: OnyxTypes.ReportAction = { + ...createRandomReportAction(REPORT_ACTION_ID), + reportActionID: '1', + actorAccountID: TEST_USER_ACCOUNT_ID, + childReportID: CHILD_REPORT_ID, + }; + const testBetas = [CONST.BETAS.ALL]; + + await TestHelper.signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN); + Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${PARENT_REPORT_ID}`, PARENT_REPORT); + await waitForBatchedUpdates(); + + expect(() => { + Report.toggleSubscribeToChildReport(CHILD_REPORT_ID, TEST_USER_ACCOUNT_ID, PARENT_REPORT_ACTION, PARENT_REPORT, INTRO_SELECTED, testBetas, 'hidden'); + }).not.toThrow(); + }); + + it('should pass betas through to openReport when creating a new child report', async () => { + const PARENT_REPORT = createRandomReport(Number(PARENT_REPORT_ID), undefined); + const PARENT_REPORT_ACTION: OnyxTypes.ReportAction = { + ...createRandomReportAction(REPORT_ACTION_ID), + reportActionID: '1', + actorAccountID: TEST_USER_ACCOUNT_ID, + }; + const testBetas = [CONST.BETAS.ALL]; + + await TestHelper.signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN); + await TestHelper.setPersonalDetails(TEST_USER_LOGIN, TEST_USER_ACCOUNT_ID); + Onyx.set(`${ONYXKEYS.COLLECTION.REPORT}${PARENT_REPORT_ID}`, PARENT_REPORT); + await waitForBatchedUpdates(); + + expect(() => { + Report.toggleSubscribeToChildReport(undefined, TEST_USER_ACCOUNT_ID, PARENT_REPORT_ACTION, PARENT_REPORT, INTRO_SELECTED, testBetas); + }).not.toThrow(); + }); }); describe('buildOptimisticResolvedFollowups', () => {