diff --git a/src/libs/actions/Report/index.ts b/src/libs/actions/Report/index.ts index f70722b296bb1..84cb2047313d1 100644 --- a/src/libs/actions/Report/index.ts +++ b/src/libs/actions/Report/index.ts @@ -2098,8 +2098,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())); } @@ -2115,6 +2116,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 @@ -2142,6 +2144,7 @@ function createChildReport( newReportObject: newChat, parentReportActionID: parentReportAction.reportActionID, isNewThread: true, + betas, }); } else { Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${childReportID}`, newChat); @@ -2161,6 +2164,7 @@ function explain( translate: LocalizedTranslate, currentUserAccountID: number, introSelected: OnyxEntry, + betas: OnyxEntry, timezone: Timezone = CONST.DEFAULT_TIME_ZONE, ) { if (!originalReport?.reportID || !reportAction) { @@ -2168,7 +2172,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 @@ -2948,10 +2952,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( @@ -2992,6 +2997,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 87d679e61d85a..1831f79f3a9ad 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, @@ -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, @@ -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/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/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 0ec80725d83d8..64aa7f0bc41f5 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,11 +4327,32 @@ 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)); }); + + 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', () => { @@ -4361,13 +4382,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 +4407,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 +4426,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 +4450,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,11 +4470,32 @@ 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)); }); + + 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', () => { @@ -4478,7 +4520,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 +4538,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 +4556,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 +4574,53 @@ 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(); + }); + + 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(); }); });