From 986cf6e43263d008bc3ff37b3c9bbf54d5019520 Mon Sep 17 00:00:00 2001 From: huutech <20178761+huult@users.noreply.github.com> Date: Thu, 12 Mar 2026 23:01:22 +0700 Subject: [PATCH 1/6] migrate report setting write capability --- src/ROUTES.ts | 9 ++++----- src/SCREENS.ts | 2 +- .../ModalStackNavigators/index.tsx | 2 +- src/libs/Navigation/linkingConfig/config.ts | 4 +--- src/libs/Navigation/types.ts | 6 ++---- .../inbox/report/withReportOrNotFound.tsx | 1 + ...age.tsx => DynamicWriteCapabilityPage.tsx} | 19 ++++++++----------- .../settings/Report/ReportSettingsPage.tsx | 4 +++- 8 files changed, 21 insertions(+), 26 deletions(-) rename src/pages/settings/Report/{WriteCapabilityPage.tsx => DynamicWriteCapabilityPage.tsx} (74%) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index ef525cbf8fc57..2551b2921e9b1 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -99,6 +99,10 @@ const DYNAMIC_ROUTES = { path: 'owner-selector', entryScreens: [], }, + REPORT_SETTINGS_WRITE_CAPABILITY: { + path: 'settings/who-can-post', + entryScreens: [SCREENS.REPORT_DETAILS.ROOT, SCREENS.RIGHT_MODAL.REPORT_SETTINGS, SCREENS.REPORT, SCREENS.RIGHT_MODAL.SEARCH_REPORT, SCREENS.SEARCH.ROOT], + }, ADDRESS_COUNTRY: { path: 'country', entryScreens: [ @@ -804,12 +808,7 @@ const ROUTES = { // eslint-disable-next-line no-restricted-syntax -- Legacy route generation getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/settings/notification-preferences` as const, backTo), }, - REPORT_SETTINGS_WRITE_CAPABILITY: { - route: 'r/:reportID/settings/who-can-post', - // eslint-disable-next-line no-restricted-syntax -- Legacy route generation - getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/settings/who-can-post` as const, backTo), - }, REPORT_SETTINGS_VISIBILITY: { route: 'r/:reportID/settings/visibility', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 6c2599a91dc50..339f09f383621 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -444,8 +444,8 @@ const SCREENS = { REPORT_SETTINGS: { ROOT: 'Report_Settings_Root', NAME: 'Report_Settings_Name', + DYNAMIC_SETTINGS_WRITE_CAPABILITY: 'Dynamic_Report_Settings_Write_Capability', NOTIFICATION_PREFERENCES: 'Report_Settings_Notification_Preferences', - WRITE_CAPABILITY: 'Report_Settings_Write_Capability', VISIBILITY: 'Report_Settings_Visibility', REPORT_LAYOUT: 'Report_Settings_Report_Layout', COLUMNS: 'Report_Settings_Columns', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 30d5ba47887e8..d5ef0c4cc25f3 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -278,8 +278,8 @@ const ReportChangeApproverModalStackNavigator = createModalStackNavigator({ [SCREENS.REPORT_SETTINGS.ROOT]: () => require('../../../../pages/settings/Report/ReportSettingsPage').default, [SCREENS.REPORT_SETTINGS.NAME]: () => require('../../../../pages/settings/Report/NamePage').default, + [SCREENS.REPORT_SETTINGS.DYNAMIC_SETTINGS_WRITE_CAPABILITY]: () => require('../../../../pages/settings/Report/DynamicWriteCapabilityPage').default, [SCREENS.REPORT_SETTINGS.NOTIFICATION_PREFERENCES]: () => require('../../../../pages/settings/Report/NotificationPreferencePage').default, - [SCREENS.REPORT_SETTINGS.WRITE_CAPABILITY]: () => require('../../../../pages/settings/Report/WriteCapabilityPage').default, [SCREENS.REPORT_SETTINGS.VISIBILITY]: () => require('../../../../pages/settings/Report/VisibilityPage').default, [SCREENS.REPORT_SETTINGS.REPORT_LAYOUT]: () => require('../../../../pages/settings/Report/ReportLayoutPage').default, [SCREENS.REPORT_SETTINGS.COLUMNS]: () => require('../../../../pages/settings/Report/ReportDetailsColumnsPage').default, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 79d1cb30c4aaa..d076c5cd97287 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -1399,12 +1399,10 @@ const config: LinkingOptions['config'] = { [SCREENS.REPORT_SETTINGS.NAME]: { path: ROUTES.REPORT_SETTINGS_NAME.route, }, + [SCREENS.REPORT_SETTINGS.DYNAMIC_SETTINGS_WRITE_CAPABILITY]: DYNAMIC_ROUTES.REPORT_SETTINGS_WRITE_CAPABILITY.path, [SCREENS.REPORT_SETTINGS.NOTIFICATION_PREFERENCES]: { path: ROUTES.REPORT_SETTINGS_NOTIFICATION_PREFERENCES.route, }, - [SCREENS.REPORT_SETTINGS.WRITE_CAPABILITY]: { - path: ROUTES.REPORT_SETTINGS_WRITE_CAPABILITY.route, - }, [SCREENS.REPORT_SETTINGS.VISIBILITY]: { path: ROUTES.REPORT_SETTINGS_VISIBILITY.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index aeb5f3e5899f4..d76a1ff7c9c3f 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -1688,12 +1688,10 @@ type ReportSettingsNavigatorParamList = { // eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md backTo?: Routes; }; - [SCREENS.REPORT_SETTINGS.NOTIFICATION_PREFERENCES]: { + [SCREENS.REPORT_SETTINGS.DYNAMIC_SETTINGS_WRITE_CAPABILITY]: { reportID: string; - // eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md - backTo?: Routes; }; - [SCREENS.REPORT_SETTINGS.WRITE_CAPABILITY]: { + [SCREENS.REPORT_SETTINGS.NOTIFICATION_PREFERENCES]: { reportID: string; // eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md backTo?: Routes; diff --git a/src/pages/inbox/report/withReportOrNotFound.tsx b/src/pages/inbox/report/withReportOrNotFound.tsx index 22d47b46b8bf8..d68840472f846 100644 --- a/src/pages/inbox/report/withReportOrNotFound.tsx +++ b/src/pages/inbox/report/withReportOrNotFound.tsx @@ -52,6 +52,7 @@ type ScreenProps = | PlatformStackScreenProps | PlatformStackScreenProps | PlatformStackScreenProps + | PlatformStackScreenProps | PlatformStackScreenProps | PlatformStackScreenProps | PlatformStackScreenProps; diff --git a/src/pages/settings/Report/WriteCapabilityPage.tsx b/src/pages/settings/Report/DynamicWriteCapabilityPage.tsx similarity index 74% rename from src/pages/settings/Report/WriteCapabilityPage.tsx rename to src/pages/settings/Report/DynamicWriteCapabilityPage.tsx index 78658925b9755..b927b03775d4b 100644 --- a/src/pages/settings/Report/WriteCapabilityPage.tsx +++ b/src/pages/settings/Report/DynamicWriteCapabilityPage.tsx @@ -1,4 +1,3 @@ -import {useRoute} from '@react-navigation/native'; import React, {useCallback} from 'react'; import type {ValueOf} from 'type-fest'; import FullPageNotFoundView from '@components/BlockingViews/FullPageNotFoundView'; @@ -6,23 +5,21 @@ import HeaderWithBackButton from '@components/HeaderWithBackButton'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/ListItem/RadioListItem'; +import useDynamicBackPath from '@hooks/useDynamicBackPath'; import useLocalize from '@hooks/useLocalize'; import useReportIsArchived from '@hooks/useReportIsArchived'; import {updateWriteCapability as updateWriteCapabilityUtil} from '@libs/actions/Report'; import Navigation from '@libs/Navigation/Navigation'; -import type {PlatformStackRouteProp, PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import {canEditWriteCapability} from '@libs/ReportUtils'; -import type {ReportSettingsNavigatorParamList} from '@navigation/types'; import withReportOrNotFound from '@pages/inbox/report/withReportOrNotFound'; import type {WithReportOrNotFoundProps} from '@pages/inbox/report/withReportOrNotFound'; import CONST from '@src/CONST'; -import ROUTES from '@src/ROUTES'; -import type SCREENS from '@src/SCREENS'; +import {DYNAMIC_ROUTES} from '@src/ROUTES'; -type WriteCapabilityPageProps = WithReportOrNotFoundProps & PlatformStackScreenProps; +type DynamicWriteCapabilityPageProps = WithReportOrNotFoundProps; -function WriteCapabilityPage({report, policy}: WriteCapabilityPageProps) { - const route = useRoute>(); +function DynamicWriteCapabilityPage({report, policy}: DynamicWriteCapabilityPageProps) { + const backPath = useDynamicBackPath(DYNAMIC_ROUTES.REPORT_SETTINGS_WRITE_CAPABILITY.path); const {translate} = useLocalize(); const writeCapabilityOptions = Object.values(CONST.REPORT.WRITE_CAPABILITIES).map((value) => ({ value, @@ -35,8 +32,8 @@ function WriteCapabilityPage({report, policy}: WriteCapabilityPageProps) { const isAbleToEdit = canEditWriteCapability(report, policy, isReportArchived); const goBack = useCallback(() => { - Navigation.goBack(ROUTES.REPORT_SETTINGS.getRoute(report.reportID, route.params.backTo)); - }, [report.reportID, route.params.backTo]); + Navigation.goBack(backPath); + }, [backPath]); const updateWriteCapability = useCallback( (newValue: ValueOf) => { @@ -69,4 +66,4 @@ function WriteCapabilityPage({report, policy}: WriteCapabilityPageProps) { ); } -export default withReportOrNotFound()(WriteCapabilityPage); +export default withReportOrNotFound()(DynamicWriteCapabilityPage); diff --git a/src/pages/settings/Report/ReportSettingsPage.tsx b/src/pages/settings/Report/ReportSettingsPage.tsx index bfa7608ae2fbb..05c9767c57e33 100644 --- a/src/pages/settings/Report/ReportSettingsPage.tsx +++ b/src/pages/settings/Report/ReportSettingsPage.tsx @@ -9,6 +9,7 @@ import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useReportIsArchived from '@hooks/useReportIsArchived'; import useThemeStyles from '@hooks/useThemeStyles'; +import createDynamicRoute from '@libs/Navigation/helpers/dynamicRoutesUtils/createDynamicRoute'; import Navigation from '@libs/Navigation/Navigation'; import type {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; import { @@ -25,6 +26,7 @@ import type {ReportSettingsNavigatorParamList} from '@navigation/types'; import withReportOrNotFound from '@pages/inbox/report/withReportOrNotFound'; import type {WithReportOrNotFoundProps} from '@pages/inbox/report/withReportOrNotFound'; import CONST from '@src/CONST'; +import {DYNAMIC_ROUTES} from '@src/ROUTES'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; @@ -78,7 +80,7 @@ function ReportSettingsPage({report, policy, route}: ReportSettingsPageProps) { shouldShowRightIcon title={writeCapabilityText} description={translate('writeCapabilityPage.label')} - onPress={() => Navigation.navigate(ROUTES.REPORT_SETTINGS_WRITE_CAPABILITY.getRoute(reportID, backTo))} + onPress={() => Navigation.navigate(createDynamicRoute(DYNAMIC_ROUTES.REPORT_SETTINGS_WRITE_CAPABILITY.path))} /> ) : ( From 531a3846b599fee62612a4146f1e4a9ac186858d Mon Sep 17 00:00:00 2001 From: huutech <20178761+huult@users.noreply.github.com> Date: Thu, 12 Mar 2026 23:14:16 +0700 Subject: [PATCH 2/6] remove useCallback --- src/pages/settings/Report/DynamicWriteCapabilityPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/settings/Report/DynamicWriteCapabilityPage.tsx b/src/pages/settings/Report/DynamicWriteCapabilityPage.tsx index b927b03775d4b..07331f73a6b05 100644 --- a/src/pages/settings/Report/DynamicWriteCapabilityPage.tsx +++ b/src/pages/settings/Report/DynamicWriteCapabilityPage.tsx @@ -31,9 +31,9 @@ function DynamicWriteCapabilityPage({report, policy}: DynamicWriteCapabilityPage const isReportArchived = useReportIsArchived(report.reportID); const isAbleToEdit = canEditWriteCapability(report, policy, isReportArchived); - const goBack = useCallback(() => { + const goBack = () => { Navigation.goBack(backPath); - }, [backPath]); + }; const updateWriteCapability = useCallback( (newValue: ValueOf) => { From cc382254985ffa1be96363cd713ebcea6b8f7ccf Mon Sep 17 00:00:00 2001 From: huutech <20178761+huult@users.noreply.github.com> Date: Mon, 16 Mar 2026 08:45:35 +0700 Subject: [PATCH 3/6] update route path --- src/ROUTES.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 69e4e72ff2a34..0dbc071822743 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -100,8 +100,8 @@ const DYNAMIC_ROUTES = { entryScreens: [], }, REPORT_SETTINGS_WRITE_CAPABILITY: { - path: 'settings/who-can-post', - entryScreens: [SCREENS.REPORT_DETAILS.ROOT, SCREENS.RIGHT_MODAL.REPORT_SETTINGS, SCREENS.REPORT, SCREENS.RIGHT_MODAL.SEARCH_REPORT, SCREENS.SEARCH.ROOT], + path: 'who-can-post', + entryScreens: [SCREENS.REPORT_SETTINGS.ROOT], }, ADDRESS_COUNTRY: { path: 'country', From 4c903dcbdd7d3c63e04963d3f09166b190b0058d Mon Sep 17 00:00:00 2001 From: huutech <20178761+huult@users.noreply.github.com> Date: Mon, 16 Mar 2026 09:10:21 +0700 Subject: [PATCH 4/6] update import path --- src/pages/settings/Report/ReportSettingsPage.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/settings/Report/ReportSettingsPage.tsx b/src/pages/settings/Report/ReportSettingsPage.tsx index 05c9767c57e33..b45340043d7f5 100644 --- a/src/pages/settings/Report/ReportSettingsPage.tsx +++ b/src/pages/settings/Report/ReportSettingsPage.tsx @@ -26,8 +26,7 @@ import type {ReportSettingsNavigatorParamList} from '@navigation/types'; import withReportOrNotFound from '@pages/inbox/report/withReportOrNotFound'; import type {WithReportOrNotFoundProps} from '@pages/inbox/report/withReportOrNotFound'; import CONST from '@src/CONST'; -import {DYNAMIC_ROUTES} from '@src/ROUTES'; -import ROUTES from '@src/ROUTES'; +import ROUTES, {DYNAMIC_ROUTES} from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; From baf65c534f99a0c506c27bedacb4b4f2382fc349 Mon Sep 17 00:00:00 2001 From: huutech <20178761+huult@users.noreply.github.com> Date: Mon, 16 Mar 2026 09:14:16 +0700 Subject: [PATCH 5/6] update import --- .../Navigation/AppNavigator/ModalStackNavigators/index.tsx | 2 +- src/libs/Navigation/linkingConfig/config.ts | 2 +- src/libs/Navigation/types.ts | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index d5ef0c4cc25f3..985e0f09adbb2 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -278,8 +278,8 @@ const ReportChangeApproverModalStackNavigator = createModalStackNavigator({ [SCREENS.REPORT_SETTINGS.ROOT]: () => require('../../../../pages/settings/Report/ReportSettingsPage').default, [SCREENS.REPORT_SETTINGS.NAME]: () => require('../../../../pages/settings/Report/NamePage').default, - [SCREENS.REPORT_SETTINGS.DYNAMIC_SETTINGS_WRITE_CAPABILITY]: () => require('../../../../pages/settings/Report/DynamicWriteCapabilityPage').default, [SCREENS.REPORT_SETTINGS.NOTIFICATION_PREFERENCES]: () => require('../../../../pages/settings/Report/NotificationPreferencePage').default, + [SCREENS.REPORT_SETTINGS.DYNAMIC_SETTINGS_WRITE_CAPABILITY]: () => require('../../../../pages/settings/Report/DynamicWriteCapabilityPage').default, [SCREENS.REPORT_SETTINGS.VISIBILITY]: () => require('../../../../pages/settings/Report/VisibilityPage').default, [SCREENS.REPORT_SETTINGS.REPORT_LAYOUT]: () => require('../../../../pages/settings/Report/ReportLayoutPage').default, [SCREENS.REPORT_SETTINGS.COLUMNS]: () => require('../../../../pages/settings/Report/ReportDetailsColumnsPage').default, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index b465e0dde3034..2cabca392df2a 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -1399,10 +1399,10 @@ const config: LinkingOptions['config'] = { [SCREENS.REPORT_SETTINGS.NAME]: { path: ROUTES.REPORT_SETTINGS_NAME.route, }, - [SCREENS.REPORT_SETTINGS.DYNAMIC_SETTINGS_WRITE_CAPABILITY]: DYNAMIC_ROUTES.REPORT_SETTINGS_WRITE_CAPABILITY.path, [SCREENS.REPORT_SETTINGS.NOTIFICATION_PREFERENCES]: { path: ROUTES.REPORT_SETTINGS_NOTIFICATION_PREFERENCES.route, }, + [SCREENS.REPORT_SETTINGS.DYNAMIC_SETTINGS_WRITE_CAPABILITY]: DYNAMIC_ROUTES.REPORT_SETTINGS_WRITE_CAPABILITY.path, [SCREENS.REPORT_SETTINGS.VISIBILITY]: { path: ROUTES.REPORT_SETTINGS_VISIBILITY.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 8b55c677fce78..48a3956e3a231 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -1688,14 +1688,14 @@ type ReportSettingsNavigatorParamList = { // eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md backTo?: Routes; }; - [SCREENS.REPORT_SETTINGS.DYNAMIC_SETTINGS_WRITE_CAPABILITY]: { - reportID: string; - }; [SCREENS.REPORT_SETTINGS.NOTIFICATION_PREFERENCES]: { reportID: string; // eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md backTo?: Routes; }; + [SCREENS.REPORT_SETTINGS.DYNAMIC_SETTINGS_WRITE_CAPABILITY]: { + reportID: string; + }; [SCREENS.REPORT_SETTINGS.VISIBILITY]: { reportID: string; // eslint-disable-next-line no-restricted-syntax -- `backTo` usages in this file are legacy. Do not add new `backTo` params to screens. See contributingGuides/NAVIGATION.md From 2fe203f680b0df3e9ff143ee8a3d41178e87489d Mon Sep 17 00:00:00 2001 From: huutech <20178761+huult@users.noreply.github.com> Date: Mon, 16 Mar 2026 09:25:12 +0700 Subject: [PATCH 6/6] update order --- src/SCREENS.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 339f09f383621..4123d7508236c 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -444,8 +444,8 @@ const SCREENS = { REPORT_SETTINGS: { ROOT: 'Report_Settings_Root', NAME: 'Report_Settings_Name', - DYNAMIC_SETTINGS_WRITE_CAPABILITY: 'Dynamic_Report_Settings_Write_Capability', NOTIFICATION_PREFERENCES: 'Report_Settings_Notification_Preferences', + DYNAMIC_SETTINGS_WRITE_CAPABILITY: 'Dynamic_Report_Settings_Write_Capability', VISIBILITY: 'Report_Settings_Visibility', REPORT_LAYOUT: 'Report_Settings_Report_Layout', COLUMNS: 'Report_Settings_Columns',