From 7c6e8c8bfa4f822566ba14cbd84cbd2ab9a99522 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 23 Jul 2026 18:46:58 +0800 Subject: [PATCH] pass hasReportActions --- src/libs/actions/Report/index.ts | 44 ++-- .../report/ContextMenu/ContextMenuActions.tsx | 62 +++--- tests/actions/ReportTest.ts | 206 +++++++++++------- 3 files changed, 197 insertions(+), 115 deletions(-) diff --git a/src/libs/actions/Report/index.ts b/src/libs/actions/Report/index.ts index 3ae815e31bd9..68be0e35f245 100644 --- a/src/libs/actions/Report/index.ts +++ b/src/libs/actions/Report/index.ts @@ -2304,6 +2304,7 @@ function createTransactionThreadReport(params: CreateTransactionThreadReportPara isSelfTourViewed, hasCompletedGuidedSetupFlow, betas, + hasReportActions: false, }); return optimisticTransactionThread; } @@ -2641,6 +2642,7 @@ function createChildReport( isNewThread: true, betas, isSelfTourViewed, + hasReportActions: false, }); } else { Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${childReportID}`, newChat); @@ -3555,6 +3557,20 @@ function updateRoomVisibility(reportID: string, previousValue: RoomVisibility | API.write(WRITE_COMMANDS.UPDATE_ROOM_VISIBILITY, parameters, {optimisticData, failureData}); } +type ToggleSubscribeToChildReportParams = { + childReportID: string | undefined; + currentUserAccountID: number; + parentReportAction: ReportAction; + parentReport: OnyxEntry; + introSelected: OnyxEntry; + isSelfTourViewed: boolean | undefined; + hasCompletedGuidedSetupFlow: boolean | undefined; + betas: OnyxEntry; + prevNotificationPreference: NotificationPreference | undefined; + personalDetails: OnyxEntry; + hasReportActions: boolean; +}; + /** * This will subscribe to an existing thread, or create a new one and then subscribe to it if necessary * @@ -3563,20 +3579,21 @@ function updateRoomVisibility(reportID: string, previousValue: RoomVisibility | * @param parentReport The parent report * @param prevNotificationPreference The previous notification preference for the child report */ -function toggleSubscribeToChildReport( - childReportID: string | undefined, - currentUserAccountID: number, - parentReportAction: ReportAction, - parentReport: OnyxEntry, - introSelected: OnyxEntry, - isSelfTourViewed: boolean | undefined, - hasCompletedGuidedSetupFlow: boolean | undefined, - betas: OnyxEntry, - prevNotificationPreference: NotificationPreference | undefined, - personalDetails: OnyxEntry, -) { +function toggleSubscribeToChildReport({ + childReportID, + currentUserAccountID, + parentReportAction, + parentReport, + introSelected, + isSelfTourViewed, + hasCompletedGuidedSetupFlow, + betas, + prevNotificationPreference, + personalDetails, + hasReportActions, +}: ToggleSubscribeToChildReportParams) { if (childReportID) { - openReport({reportID: childReportID, introSelected, betas, isSelfTourViewed, hasCompletedGuidedSetupFlow}); + openReport({reportID: childReportID, introSelected, betas, isSelfTourViewed, hasCompletedGuidedSetupFlow, hasReportActions}); const parentReportActionID = parentReportAction.reportActionID; if (!prevNotificationPreference || isHiddenForCurrentUser(prevNotificationPreference)) { updateNotificationPreference( @@ -3623,6 +3640,7 @@ function toggleSubscribeToChildReport( isSelfTourViewed, hasCompletedGuidedSetupFlow, betas, + hasReportActions: false, }); 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 a78ff43799c1..c4923f818207 100644 --- a/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx @@ -760,40 +760,45 @@ const ContextMenuActions: ContextMenuAction[] = [ (shouldDisplayThreadReplies || (!isDeletedAction && !isArchivedRoom)) ); }, - onPress: (closePopover, {reportAction, currentUserAccountID, originalReport, introSelected, isSelfTourViewed, hasCompletedGuidedSetupFlow, betas, personalDetails}) => { + onPress: ( + closePopover, + {reportAction, currentUserAccountID, originalReport, introSelected, isSelfTourViewed, hasCompletedGuidedSetupFlow, betas, personalDetails, childReportActions}, + ) => { const childReportNotificationPreference = getChildReportNotificationPreferenceReportUtils(reportAction); if (closePopover) { hideContextMenu(false, () => { ReportActionComposeFocusManager.focus(); - toggleSubscribeToChildReport( - reportAction?.childReportID, + toggleSubscribeToChildReport({ + childReportID: reportAction?.childReportID, currentUserAccountID, - reportAction, - originalReport, + parentReportAction: reportAction, + parentReport: originalReport, introSelected, isSelfTourViewed, hasCompletedGuidedSetupFlow, betas, - childReportNotificationPreference, + prevNotificationPreference: childReportNotificationPreference, personalDetails, - ); + hasReportActions: !!childReportActions, + }); }); return; } ReportActionComposeFocusManager.focus(); - toggleSubscribeToChildReport( - reportAction?.childReportID, + toggleSubscribeToChildReport({ + childReportID: reportAction?.childReportID, currentUserAccountID, - reportAction, - originalReport, + parentReportAction: reportAction, + parentReport: originalReport, introSelected, isSelfTourViewed, hasCompletedGuidedSetupFlow, betas, - childReportNotificationPreference, + prevNotificationPreference: childReportNotificationPreference, personalDetails, - ); + hasReportActions: !!childReportActions, + }); }, getDescription: () => {}, sentryLabel: CONST.SENTRY_LABEL.CONTEXT_MENU.JOIN_THREAD, @@ -821,40 +826,45 @@ const ContextMenuActions: ContextMenuAction[] = [ (shouldDisplayThreadReplies || (!isDeletedAction && !isArchivedRoom)) ); }, - onPress: (closePopover, {reportAction, currentUserAccountID, originalReport, introSelected, isSelfTourViewed, hasCompletedGuidedSetupFlow, betas, personalDetails}) => { + onPress: ( + closePopover, + {reportAction, currentUserAccountID, originalReport, introSelected, isSelfTourViewed, hasCompletedGuidedSetupFlow, betas, personalDetails, childReportActions}, + ) => { const childReportNotificationPreference = getChildReportNotificationPreferenceReportUtils(reportAction); if (closePopover) { hideContextMenu(false, () => { ReportActionComposeFocusManager.focus(); - toggleSubscribeToChildReport( - reportAction?.childReportID, + toggleSubscribeToChildReport({ + childReportID: reportAction?.childReportID, currentUserAccountID, - reportAction, - originalReport, + parentReportAction: reportAction, + parentReport: originalReport, introSelected, isSelfTourViewed, hasCompletedGuidedSetupFlow, betas, - childReportNotificationPreference, + prevNotificationPreference: childReportNotificationPreference, personalDetails, - ); + hasReportActions: !!childReportActions, + }); }); return; } ReportActionComposeFocusManager.focus(); - toggleSubscribeToChildReport( - reportAction?.childReportID, + toggleSubscribeToChildReport({ + childReportID: reportAction?.childReportID, currentUserAccountID, - reportAction, - originalReport, + parentReportAction: reportAction, + parentReport: originalReport, introSelected, isSelfTourViewed, hasCompletedGuidedSetupFlow, betas, - childReportNotificationPreference, + prevNotificationPreference: childReportNotificationPreference, personalDetails, - ); + hasReportActions: !!childReportActions, + }); }, getDescription: () => {}, sentryLabel: CONST.SENTRY_LABEL.CONTEXT_MENU.LEAVE_THREAD, diff --git a/tests/actions/ReportTest.ts b/tests/actions/ReportTest.ts index 6517be85e3e1..7f273528c817 100644 --- a/tests/actions/ReportTest.ts +++ b/tests/actions/ReportTest.ts @@ -5994,18 +5994,19 @@ describe('actions/Report', () => { await waitForBatchedUpdates(); expect(() => { - Report.toggleSubscribeToChildReport( - CHILD_REPORT_ID, - TEST_USER_ACCOUNT_ID, - PARENT_REPORT_ACTION, - PARENT_REPORT, - INTRO_SELECTED, - false, - undefined, - undefined, - 'hidden', - undefined, - ); + Report.toggleSubscribeToChildReport({ + childReportID: CHILD_REPORT_ID, + currentUserAccountID: TEST_USER_ACCOUNT_ID, + parentReportAction: PARENT_REPORT_ACTION, + parentReport: PARENT_REPORT, + introSelected: INTRO_SELECTED, + isSelfTourViewed: false, + hasCompletedGuidedSetupFlow: undefined, + betas: undefined, + prevNotificationPreference: 'hidden', + personalDetails: undefined, + hasReportActions: false, + }); }).not.toThrow(); }); @@ -6023,7 +6024,19 @@ describe('actions/Report', () => { await waitForBatchedUpdates(); expect(() => { - Report.toggleSubscribeToChildReport(undefined, TEST_USER_ACCOUNT_ID, PARENT_REPORT_ACTION, PARENT_REPORT, INTRO_SELECTED, false, undefined, undefined, undefined, undefined); + Report.toggleSubscribeToChildReport({ + childReportID: undefined, + currentUserAccountID: TEST_USER_ACCOUNT_ID, + parentReportAction: PARENT_REPORT_ACTION, + parentReport: PARENT_REPORT, + introSelected: INTRO_SELECTED, + isSelfTourViewed: false, + hasCompletedGuidedSetupFlow: undefined, + betas: undefined, + prevNotificationPreference: undefined, + personalDetails: undefined, + hasReportActions: false, + }); }).not.toThrow(); }); @@ -6041,7 +6054,19 @@ describe('actions/Report', () => { await waitForBatchedUpdates(); expect(() => { - Report.toggleSubscribeToChildReport(CHILD_REPORT_ID, TEST_USER_ACCOUNT_ID, PARENT_REPORT_ACTION, PARENT_REPORT, undefined, true, undefined, undefined, 'hidden', undefined); + Report.toggleSubscribeToChildReport({ + childReportID: CHILD_REPORT_ID, + currentUserAccountID: TEST_USER_ACCOUNT_ID, + parentReportAction: PARENT_REPORT_ACTION, + parentReport: PARENT_REPORT, + introSelected: undefined, + isSelfTourViewed: true, + hasCompletedGuidedSetupFlow: undefined, + betas: undefined, + prevNotificationPreference: 'hidden', + personalDetails: undefined, + hasReportActions: false, + }); }).not.toThrow(); }); @@ -6059,18 +6084,19 @@ describe('actions/Report', () => { await waitForBatchedUpdates(); expect(() => { - Report.toggleSubscribeToChildReport( - CHILD_REPORT_ID, - TEST_USER_ACCOUNT_ID, - PARENT_REPORT_ACTION, - PARENT_REPORT, - INTRO_SELECTED, - true, - undefined, - undefined, - CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, - undefined, - ); + Report.toggleSubscribeToChildReport({ + childReportID: CHILD_REPORT_ID, + currentUserAccountID: TEST_USER_ACCOUNT_ID, + parentReportAction: PARENT_REPORT_ACTION, + parentReport: PARENT_REPORT, + introSelected: INTRO_SELECTED, + isSelfTourViewed: true, + hasCompletedGuidedSetupFlow: undefined, + betas: undefined, + prevNotificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, + personalDetails: undefined, + hasReportActions: false, + }); }).not.toThrow(); }); @@ -6088,7 +6114,19 @@ describe('actions/Report', () => { await waitForBatchedUpdates(); expect(() => { - Report.toggleSubscribeToChildReport(undefined, TEST_USER_ACCOUNT_ID, PARENT_REPORT_ACTION, PARENT_REPORT, INTRO_SELECTED, true, undefined, undefined, undefined, undefined); + Report.toggleSubscribeToChildReport({ + childReportID: undefined, + currentUserAccountID: TEST_USER_ACCOUNT_ID, + parentReportAction: PARENT_REPORT_ACTION, + parentReport: PARENT_REPORT, + introSelected: INTRO_SELECTED, + isSelfTourViewed: true, + hasCompletedGuidedSetupFlow: undefined, + betas: undefined, + prevNotificationPreference: undefined, + personalDetails: undefined, + hasReportActions: false, + }); }).not.toThrow(); }); @@ -6106,7 +6144,19 @@ describe('actions/Report', () => { await waitForBatchedUpdates(); expect(() => { - Report.toggleSubscribeToChildReport(undefined, TEST_USER_ACCOUNT_ID, PARENT_REPORT_ACTION, PARENT_REPORT, INTRO_SELECTED, false, undefined, undefined, undefined, undefined); + Report.toggleSubscribeToChildReport({ + childReportID: undefined, + currentUserAccountID: TEST_USER_ACCOUNT_ID, + parentReportAction: PARENT_REPORT_ACTION, + parentReport: PARENT_REPORT, + introSelected: INTRO_SELECTED, + isSelfTourViewed: false, + hasCompletedGuidedSetupFlow: undefined, + betas: undefined, + prevNotificationPreference: undefined, + personalDetails: undefined, + hasReportActions: false, + }); }).not.toThrow(); }); @@ -6124,18 +6174,19 @@ describe('actions/Report', () => { await waitForBatchedUpdates(); expect(() => { - Report.toggleSubscribeToChildReport( - CHILD_REPORT_ID, - TEST_USER_ACCOUNT_ID, - PARENT_REPORT_ACTION, - PARENT_REPORT, - INTRO_SELECTED, - true, - undefined, - undefined, - 'hidden', - undefined, - ); + Report.toggleSubscribeToChildReport({ + childReportID: CHILD_REPORT_ID, + currentUserAccountID: TEST_USER_ACCOUNT_ID, + parentReportAction: PARENT_REPORT_ACTION, + parentReport: PARENT_REPORT, + introSelected: INTRO_SELECTED, + isSelfTourViewed: true, + hasCompletedGuidedSetupFlow: undefined, + betas: undefined, + prevNotificationPreference: 'hidden', + personalDetails: undefined, + hasReportActions: false, + }); }).not.toThrow(); }); @@ -6153,18 +6204,19 @@ describe('actions/Report', () => { await waitForBatchedUpdates(); expect(() => { - Report.toggleSubscribeToChildReport( - CHILD_REPORT_ID, - TEST_USER_ACCOUNT_ID, - PARENT_REPORT_ACTION, - PARENT_REPORT, - INTRO_SELECTED, - false, - undefined, - undefined, - undefined, - undefined, - ); + Report.toggleSubscribeToChildReport({ + childReportID: CHILD_REPORT_ID, + currentUserAccountID: TEST_USER_ACCOUNT_ID, + parentReportAction: PARENT_REPORT_ACTION, + parentReport: PARENT_REPORT, + introSelected: INTRO_SELECTED, + isSelfTourViewed: false, + hasCompletedGuidedSetupFlow: undefined, + betas: undefined, + prevNotificationPreference: undefined, + personalDetails: undefined, + hasReportActions: false, + }); }).not.toThrow(); }); @@ -6183,18 +6235,19 @@ describe('actions/Report', () => { await waitForBatchedUpdates(); expect(() => { - Report.toggleSubscribeToChildReport( - CHILD_REPORT_ID, - TEST_USER_ACCOUNT_ID, - PARENT_REPORT_ACTION, - PARENT_REPORT, - INTRO_SELECTED, - undefined, - undefined, - testBetas, - 'hidden', - undefined, - ); + Report.toggleSubscribeToChildReport({ + childReportID: CHILD_REPORT_ID, + currentUserAccountID: TEST_USER_ACCOUNT_ID, + parentReportAction: PARENT_REPORT_ACTION, + parentReport: PARENT_REPORT, + introSelected: INTRO_SELECTED, + isSelfTourViewed: undefined, + hasCompletedGuidedSetupFlow: undefined, + betas: testBetas, + prevNotificationPreference: 'hidden', + personalDetails: undefined, + hasReportActions: false, + }); }).not.toThrow(); }); @@ -6213,18 +6266,19 @@ describe('actions/Report', () => { await waitForBatchedUpdates(); expect(() => { - Report.toggleSubscribeToChildReport( - undefined, - TEST_USER_ACCOUNT_ID, - PARENT_REPORT_ACTION, - PARENT_REPORT, - INTRO_SELECTED, - undefined, - undefined, - testBetas, - undefined, - undefined, - ); + Report.toggleSubscribeToChildReport({ + childReportID: undefined, + currentUserAccountID: TEST_USER_ACCOUNT_ID, + parentReportAction: PARENT_REPORT_ACTION, + parentReport: PARENT_REPORT, + introSelected: INTRO_SELECTED, + isSelfTourViewed: undefined, + hasCompletedGuidedSetupFlow: undefined, + betas: testBetas, + prevNotificationPreference: undefined, + personalDetails: undefined, + hasReportActions: false, + }); }).not.toThrow(); }); });