Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 31 additions & 13 deletions src/libs/actions/Report/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2361,6 +2361,7 @@ function createTransactionThreadReport(params: CreateTransactionThreadReportPara
isSelfTourViewed,
hasCompletedGuidedSetupFlow,
betas,
hasReportActions: false,
});
return optimisticTransactionThread;
}
Expand Down Expand Up @@ -2702,6 +2703,7 @@ function createChildReport(
isNewThread: true,
betas,
isSelfTourViewed,
hasReportActions: false,
currentUserAccountID,
});
} else {
Expand Down Expand Up @@ -3618,6 +3620,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<Report>;
introSelected: OnyxEntry<IntroSelected>;
isSelfTourViewed: boolean | undefined;
hasCompletedGuidedSetupFlow: boolean | undefined;
betas: OnyxEntry<Beta[]>;
prevNotificationPreference: NotificationPreference | undefined;
personalDetails: OnyxEntry<PersonalDetailsList>;
hasReportActions: boolean;
};

/**
* This will subscribe to an existing thread, or create a new one and then subscribe to it if necessary
*
Expand All @@ -3626,20 +3642,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<Report>,
introSelected: OnyxEntry<IntroSelected>,
isSelfTourViewed: boolean | undefined,
hasCompletedGuidedSetupFlow: boolean | undefined,
betas: OnyxEntry<Beta[]>,
prevNotificationPreference: NotificationPreference | undefined,
personalDetails: OnyxEntry<PersonalDetailsList>,
) {
function toggleSubscribeToChildReport({
childReportID,
currentUserAccountID,
parentReportAction,
parentReport,
introSelected,
isSelfTourViewed,
hasCompletedGuidedSetupFlow,
betas,
prevNotificationPreference,
personalDetails,
hasReportActions,
}: ToggleSubscribeToChildReportParams) {
if (childReportID) {
openReport({reportID: childReportID, introSelected, betas, isSelfTourViewed, hasCompletedGuidedSetupFlow, currentUserAccountID});
openReport({reportID: childReportID, introSelected, betas, isSelfTourViewed, hasCompletedGuidedSetupFlow, hasReportActions, currentUserAccountID});
const parentReportActionID = parentReportAction.reportActionID;
if (!prevNotificationPreference || isHiddenForCurrentUser(prevNotificationPreference)) {
updateNotificationPreference(
Expand Down Expand Up @@ -3686,6 +3703,7 @@ function toggleSubscribeToChildReport(
isSelfTourViewed,
hasCompletedGuidedSetupFlow,
betas,
hasReportActions: false,
currentUserAccountID,
});
const notificationPreference = isHiddenForCurrentUser(prevNotificationPreference) ? CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS : CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN;
Expand Down
62 changes: 36 additions & 26 deletions src/pages/inbox/report/ContextMenu/ContextMenuActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -764,40 +764,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,
Expand Down Expand Up @@ -825,40 +830,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,
Expand Down
Loading
Loading