diff --git a/src/Expensify.js b/src/Expensify.js index 407e5ae09c2d..d9282229b749 100644 --- a/src/Expensify.js +++ b/src/Expensify.js @@ -23,7 +23,8 @@ import compose from './libs/compose'; import * as Growl from './libs/Growl'; import Log from './libs/Log'; import migrateOnyx from './libs/migrateOnyx'; -import Navigation from './libs/Navigation/Navigation'; +import getTopmostBottomTabRoute from './libs/Navigation/getTopmostBottomTabRoute'; +import Navigation, {navigationRef} from './libs/Navigation/Navigation'; import NavigationRoot from './libs/Navigation/NavigationRoot'; import NetworkConnection from './libs/NetworkConnection'; import PushNotification from './libs/Notification/PushNotification'; @@ -37,6 +38,7 @@ import Visibility from './libs/Visibility'; import ONYXKEYS from './ONYXKEYS'; import PopoverReportActionContextMenu from './pages/home/report/ContextMenu/PopoverReportActionContextMenu'; import * as ReportActionContextMenu from './pages/home/report/ContextMenu/ReportActionContextMenu'; +import SCREENS from './SCREENS'; Onyx.registerLogger(({level, message}) => { if (level === 'alert') { @@ -130,7 +132,16 @@ function Expensify(props) { [isSplashHidden], ); - const shouldInit = isNavigationReady && (!isAuthenticated || props.isSidebarLoaded) && hasAttemptedToOpenPublicRoom; + // This is a temporary fix to handle more that one possible screen in the sidebar. + const isSidebarLoaded = useMemo(() => { + if (!isNavigationReady) { + return false; + } + + return getTopmostBottomTabRoute(navigationRef.getState()).name === SCREENS.HOME ? props.isSidebarLoaded : true; + }, [isNavigationReady, props.isSidebarLoaded]); + + const shouldInit = isNavigationReady && (!isAuthenticated || isSidebarLoaded) && hasAttemptedToOpenPublicRoom; const shouldHideSplash = shouldInit && !isSplashHidden; const initializeClient = () => { diff --git a/src/components/AttachmentModal.tsx b/src/components/AttachmentModal.tsx index 5d826da71e90..f3e8ed316c52 100755 --- a/src/components/AttachmentModal.tsx +++ b/src/components/AttachmentModal.tsx @@ -281,7 +281,7 @@ function AttachmentModal({ const deleteAndCloseModal = useCallback(() => { IOU.detachReceipt(transaction?.transactionID); setIsDeleteReceiptConfirmModalVisible(false); - Navigation.dismissModalWithReportID(report?.reportID ?? ''); + Navigation.dismissModal(report?.reportID); }, [transaction, report]); const isValidFile = useCallback((fileObject: FileObject) => { diff --git a/src/components/ReportHeaderSkeletonView.tsx b/src/components/ReportHeaderSkeletonView.tsx index 8b8bb721a5dc..2113abd85e88 100644 --- a/src/components/ReportHeaderSkeletonView.tsx +++ b/src/components/ReportHeaderSkeletonView.tsx @@ -25,7 +25,7 @@ function ReportHeaderSkeletonView({shouldAnimate = true, onBackButtonPress = () return ( - + {isSmallScreenWidth && ( diff --git a/src/libs/Navigation/Navigation.ts b/src/libs/Navigation/Navigation.ts index f293ac1a9127..188d8b5f337f 100644 --- a/src/libs/Navigation/Navigation.ts +++ b/src/libs/Navigation/Navigation.ts @@ -18,7 +18,7 @@ import linkingConfig from './linkingConfig'; import linkTo from './linkTo'; import navigationRef from './navigationRef'; import switchPolicyID from './switchPolicyID'; -import type {State, StateOrRoute, switchPolicyIDParams} from './types'; +import type {State, StateOrRoute, SwitchPolicyIDParams} from './types'; let resolveNavigationIsReadyPromise: () => void; const navigationIsReadyPromise = new Promise((resolve) => { @@ -51,17 +51,20 @@ const getTopmostReportId = (state = navigationRef.getState()) => originalGetTopm const getTopmostReportActionId = (state = navigationRef.getState()) => originalGetTopmostReportActionId(state); // Re-exporting the dismissModal here to fill in default value for navigationRef. The dismissModal isn't defined in this file to avoid cyclic dependencies. -const dismissModal = (ref = navigationRef) => originalDismissModal(ref); +const dismissModal = (reportID?: string, ref = navigationRef) => { + if (!reportID) { + originalDismissModal(ref); + return; + } + const report = getReport(reportID); + originalDismissModalWithReport({reportID, ...report}, ref); +}; // Re-exporting the dismissModalWithReport here to fill in default value for navigationRef. The dismissModalWithReport isn't defined in this file to avoid cyclic dependencies. // This method is needed because it allows to dismiss the modal and then open the report. Within this method is checked whether the report belongs to a specific workspace. Sometimes the report we want to check, hasn't been added to the Onyx yet. // Then we can pass the report as a param without getting it from the Onyx. const dismissModalWithReport = (report: Report | EmptyObject, ref = navigationRef) => originalDismissModalWithReport(report, ref); -const dismissModalWithReportID = (reportID: string, ref = navigationRef) => { - const report = getReport(reportID); - originalDismissModalWithReport({reportID, ...report}, ref); -}; /** Method for finding on which index in stack we are. */ function getActiveRouteIndex(stateOrRoute: StateOrRoute, index?: number): number | undefined { if ('routes' in stateOrRoute && stateOrRoute.routes) { @@ -323,7 +326,7 @@ function waitForProtectedRoutes() { }); } -function navigateWithSwitchPolicyID(params: switchPolicyIDParams) { +function navigateWithSwitchPolicyID(params: SwitchPolicyIDParams) { if (!canNavigate('navigateWithSwitchPolicyID')) { return; } @@ -337,7 +340,6 @@ export default { setParams, dismissModal, dismissModalWithReport, - dismissModalWithReportID, isActiveRoute, getActiveRoute, getActiveRouteWithoutParams, diff --git a/src/libs/Navigation/switchPolicyID.ts b/src/libs/Navigation/switchPolicyID.ts index fe3abaaf5546..0cbd4874e7ae 100644 --- a/src/libs/Navigation/switchPolicyID.ts +++ b/src/libs/Navigation/switchPolicyID.ts @@ -1,7 +1,7 @@ import {getActionFromState} from '@react-navigation/core'; import type {NavigationAction, NavigationContainerRef, NavigationState, PartialState} from '@react-navigation/native'; import {getPathFromState} from '@react-navigation/native'; -import type {Writable} from 'type-fest'; +import type {ValueOf, Writable} from 'type-fest'; import getIsSmallScreenWidth from '@libs/getIsSmallScreenWidth'; import CONST from '@src/CONST'; import NAVIGATORS from '@src/NAVIGATORS'; @@ -11,7 +11,7 @@ import getStateFromPath from './getStateFromPath'; import getTopmostCentralPaneRoute from './getTopmostCentralPaneRoute'; import linkingConfig from './linkingConfig'; import TAB_TO_CENTRAL_PANE_MAPPING from './linkingConfig/TAB_TO_CENTRAL_PANE_MAPPING'; -import type {NavigationRoot, RootStackParamList, StackNavigationAction, State, switchPolicyIDParams} from './types'; +import type {NavigationRoot, RootStackParamList, StackNavigationAction, State, SwitchPolicyIDParams} from './types'; type ActionPayloadParams = { screen?: string; @@ -60,7 +60,7 @@ function getActionForBottomTabNavigator(action: StackNavigationAction, state: Na }; } -export default function switchPolicyID(navigation: NavigationContainerRef | null, {policyID, route}: switchPolicyIDParams) { +export default function switchPolicyID(navigation: NavigationContainerRef | null, {policyID, route, isPolicyAdmin = false}: SwitchPolicyIDParams) { if (!navigation) { throw new Error("Couldn't find a navigation object. Is your component inside a screen in a navigator?"); } @@ -110,15 +110,21 @@ export default function switchPolicyID(navigation: NavigationContainerRef); // Only workspace settings screens have to store the policyID in the params. // In other case, the policyID is read from the BottomTab params. - if (!screen?.startsWith('Workspace_')) { + if (!isWorkspaceScreen) { delete params.policyID; } else { params.policyID = policyID; } + // We need to redirect non admin users to overview screen, when switching workspace. + if (!isPolicyAdmin && isWorkspaceScreen && screen !== SCREENS.WORKSPACE.OVERVIEW) { + screen = SCREENS.WORKSPACE.OVERVIEW; + } + // If the user is on the home page and changes the current workspace, then should be displayed a report from the selected workspace. // To achieve that, it's necessary to navigate without the reportID param. if (checkIfActionPayloadNameIsEqual(actionForBottomTabNavigator, SCREENS.HOME)) { diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 31ba56e9dec5..02d0af545710 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -470,9 +470,10 @@ type CentralPaneName = keyof CentralPaneNavigatorParamList; type FullScreenName = keyof SettingsCentralPaneNavigatorParamList; -type switchPolicyIDParams = { +type SwitchPolicyIDParams = { policyID?: string; route?: Routes; + isPolicyAdmin?: boolean; }; export type { @@ -519,5 +520,5 @@ export type { ReimbursementAccountNavigatorParamList, State, WorkspaceSwitcherNavigatorParamList, - switchPolicyIDParams, + SwitchPolicyIDParams, }; diff --git a/src/libs/actions/IOU.js b/src/libs/actions/IOU.js index d7857954ebe5..5e7396e5cd8f 100644 --- a/src/libs/actions/IOU.js +++ b/src/libs/actions/IOU.js @@ -936,7 +936,7 @@ function createDistanceRequest(report, participant, comment, created, category, }, onyxData, ); - Navigation.dismissModalWithReportID(isMoneyRequestReport ? report.reportID : chatReport.reportID); + Navigation.dismissModal(isMoneyRequestReport ? report.reportID : chatReport.reportID); Report.notifyNewAction(chatReport.reportID, userAccountID); } @@ -1364,7 +1364,7 @@ function requestMoney( onyxData, ); resetMoneyRequestInfo(); - Navigation.dismissModalWithReportID(activeReportID); + Navigation.dismissModal(activeReportID); Report.notifyNewAction(activeReportID, payeeAccountID); } @@ -1806,7 +1806,7 @@ function splitBillAndOpenReport(participants, currentUserLogin, currentUserAccou ); resetMoneyRequestInfo(); - Navigation.dismissModalWithReportID(splitData.chatReportID); + Navigation.dismissModal(splitData.chatReportID); Report.notifyNewAction(splitData.chatReportID, currentUserAccountID); } @@ -2288,7 +2288,7 @@ function completeSplitBill(chatReportID, reportAction, updatedTransaction, sessi }, {optimisticData, successData, failureData}, ); - Navigation.dismissModalWithReportID(chatReportID); + Navigation.dismissModal(chatReportID); Report.notifyNewAction(chatReportID, sessionAccountID); } @@ -3244,7 +3244,7 @@ function sendMoneyElsewhere(report, amount, currency, comment, managerID, recipi API.write('SendMoneyElsewhere', params, {optimisticData, successData, failureData}); resetMoneyRequestInfo(); - Navigation.dismissModalWithReportID(params.chatReportID); + Navigation.dismissModal(params.chatReportID); Report.notifyNewAction(params.chatReportID, managerID); } @@ -3262,7 +3262,7 @@ function sendMoneyWithWallet(report, amount, currency, comment, managerID, recip API.write('SendMoneyWithWallet', params, {optimisticData, successData, failureData}); resetMoneyRequestInfo(); - Navigation.dismissModalWithReportID(params.chatReportID); + Navigation.dismissModal(params.chatReportID); Report.notifyNewAction(params.chatReportID, managerID); } diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 0370a4bff97a..028c409ee8fa 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -1641,7 +1641,7 @@ function addPolicyReport(policyReport: ReportUtils.OptimisticChatReport) { }; API.write(WRITE_COMMANDS.ADD_WORKSPACE_ROOM, parameters, {optimisticData, successData, failureData}); - Navigation.dismissModalWithReportID(policyReport.reportID); + Navigation.dismissModal(policyReport.reportID); } /** Deletes a report, along with its reportActions, any linked reports, and any linked IOU report. */ diff --git a/src/libs/actions/Task.ts b/src/libs/actions/Task.ts index 45c036f9edb9..a7aab98f02c6 100644 --- a/src/libs/actions/Task.ts +++ b/src/libs/actions/Task.ts @@ -244,7 +244,7 @@ function createTaskAndNavigate( API.write(WRITE_COMMANDS.CREATE_TASK, parameters, {optimisticData, successData, failureData}); - Navigation.dismissModalWithReportID(parentReportID); + Navigation.dismissModal(parentReportID); } /** diff --git a/src/libs/actions/TeachersUnite.ts b/src/libs/actions/TeachersUnite.ts index c0259de50f60..055d1f2b53a2 100644 --- a/src/libs/actions/TeachersUnite.ts +++ b/src/libs/actions/TeachersUnite.ts @@ -61,7 +61,7 @@ function referTeachersUniteVolunteer(partnerUserID: string, firstName: string, l }; API.write(WRITE_COMMANDS.REFER_TEACHERS_UNITE_VOLUNTEER, parameters, {optimisticData}); - Navigation.dismissModalWithReportID(publicRoomReportID); + Navigation.dismissModal(publicRoomReportID); } /** @@ -181,7 +181,7 @@ function addSchoolPrincipal(firstName: string, partnerUserID: string, lastName: }; API.write(WRITE_COMMANDS.ADD_SCHOOL_PRINCIPAL, parameters, {optimisticData, successData, failureData}); - Navigation.dismissModalWithReportID(expenseChatReportID); + Navigation.dismissModal(expenseChatReportID); } export default {referTeachersUniteVolunteer, addSchoolPrincipal}; diff --git a/src/pages/AddPersonalBankAccountPage.tsx b/src/pages/AddPersonalBankAccountPage.tsx index f7963976dc05..1876992f9ced 100644 --- a/src/pages/AddPersonalBankAccountPage.tsx +++ b/src/pages/AddPersonalBankAccountPage.tsx @@ -47,7 +47,7 @@ function AddPersonalBankAccountPage({personalBankAccount, plaidData}: AddPersona const onSuccessFallbackRoute = personalBankAccount?.onSuccessFallbackRoute ?? ''; if (exitReportID) { - Navigation.dismissModalWithReportID(exitReportID); + Navigation.dismissModal(exitReportID); } else if (shouldContinue && onSuccessFallbackRoute) { PaymentMethods.continueSetup(onSuccessFallbackRoute); } else { diff --git a/src/pages/EditRequestDistancePage.js b/src/pages/EditRequestDistancePage.js index f4c5fbe0446f..f3ea76a3390a 100644 --- a/src/pages/EditRequestDistancePage.js +++ b/src/pages/EditRequestDistancePage.js @@ -60,7 +60,7 @@ function EditRequestDistancePage({report, route, transaction, transactionBackup} // When the loading goes from true to false, then we know the transaction has just been // saved to the server. Check for errors. If there are no errors, then the modal can be closed. if (prevIsLoading && !transaction.isLoading && !hasWaypointError.current) { - Navigation.dismissModalWithReportID(report.reportID); + Navigation.dismissModal(report.reportID); } }, [transaction, prevIsLoading, report]); @@ -75,7 +75,7 @@ function EditRequestDistancePage({report, route, transaction, transactionBackup} const oldAddresses = _.mapObject(oldWaypoints, (waypoint) => _.pick(waypoint, 'address')); const addresses = _.mapObject(waypoints, (waypoint) => _.pick(waypoint, 'address')); if (_.isEqual(oldAddresses, addresses)) { - Navigation.dismissModalWithReportID(report.reportID); + Navigation.dismissModal(report.reportID); return; } @@ -84,7 +84,7 @@ function EditRequestDistancePage({report, route, transaction, transactionBackup} // If the client is offline, then the modal can be closed as well (because there are no errors or other feedback to show them // until they come online again and sync with the server). if (isOffline) { - Navigation.dismissModalWithReportID(report.reportID); + Navigation.dismissModal(report.reportID); } }; diff --git a/src/pages/SearchPage.js b/src/pages/SearchPage.js index 76931d73e18f..d0d2a23bb563 100755 --- a/src/pages/SearchPage.js +++ b/src/pages/SearchPage.js @@ -155,7 +155,7 @@ function SearchPage({betas, personalDetails, reports, isSearchingForReports, nav return; } if (option.reportID) { - Navigation.dismissModalWithReportID(option.reportID); + Navigation.dismissModal(option.reportID); } else { Report.navigateToAndOpenReport([option.login]); } diff --git a/src/pages/SearchPage/index.js b/src/pages/SearchPage/index.js index 3fd28a39f64b..211f3622e06c 100644 --- a/src/pages/SearchPage/index.js +++ b/src/pages/SearchPage/index.js @@ -123,7 +123,7 @@ function SearchPage({betas, reports}) { if (option.reportID) { setSearchValue(''); - Navigation.dismissModalWithReportID(option.reportID); + Navigation.dismissModal(option.reportID); } else { Report.navigateToAndOpenReport([option.login]); } diff --git a/src/pages/ShareCodePage.js b/src/pages/ShareCodePage.js index 1f5dab566e2c..3f0ef6ca138e 100644 --- a/src/pages/ShareCodePage.js +++ b/src/pages/ShareCodePage.js @@ -90,13 +90,8 @@ class ShareCodePage extends React.Component { shouldShowBackButton={isReport || this.props.isSmallScreenWidth} /> - - + + { - const policyID = option.policyID; + const selectPolicy = (option) => { + const {policyID, isPolicyAdmin} = option; if (policyID) { setSelectedOption(option); @@ -121,13 +121,9 @@ function WorkspaceSwitcherPage({policies}) { setActiveWorkspaceID(policyID); Navigation.goBack(); if (policyID !== activeWorkspaceID) { - Navigation.navigateWithSwitchPolicyID({policyID}); + Navigation.navigateWithSwitchPolicyID({policyID, isPolicyAdmin}); } - }, []); - - const onChangeText = useCallback((newSearchTerm) => { - setSearchTerm(newSearchTerm); - }, []); + }; const usersWorkspaces = useMemo( () => @@ -147,6 +143,7 @@ function WorkspaceSwitcherPage({policies}) { ], boldStyle: hasUnreadData(policy.id), keyForList: policy.id, + isPolicyAdmin: PolicyUtils.isPolicyAdmin(policy), })) .value(), [policies, getIndicatorTypeForPolicy, hasUnreadData], @@ -213,7 +210,7 @@ function WorkspaceSwitcherPage({policies}) { const workspacesSection = useMemo( () => ( <> - 0 ? [styles.mb1] : [styles.mb3])]}> + 0 ? [styles.mb0] : [styles.mb3])]}> = CONST.WORKSPACE_SWITCHER.MINIMUM_WORKSPACES_TO_SHOW_SEARCH} - onChangeText={onChangeText} + onChangeText={(newSearchTerm) => setSearchTerm(newSearchTerm)} selectedOptions={selectedOption ? [selectedOption] : []} onSelectRow={selectPolicy} shouldPreventDefaultFocusOnSelectRow @@ -269,7 +266,7 @@ function WorkspaceSwitcherPage({policies}) { )} ), - [inputCallbackRef, onChangeText, searchTerm, selectPolicy, selectedOption, styles, theme.textSupporting, translate, usersWorkspaces.length, usersWorkspacesSectionData], + [inputCallbackRef, setSearchTerm, searchTerm, selectPolicy, selectedOption, styles, theme.textSupporting, translate, usersWorkspaces.length, usersWorkspacesSectionData], ); useEffect(() => { diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index 1e3d34af64e7..c2d1ecffc2a7 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -227,7 +227,7 @@ function HeaderView(props) { dataSet={{dragArea: true}} > - + {isLoading ? ( ) : ( diff --git a/src/pages/settings/Preferences/ThemePage.js b/src/pages/settings/Preferences/ThemePage.js index 95b280f76076..4907056be761 100644 --- a/src/pages/settings/Preferences/ThemePage.js +++ b/src/pages/settings/Preferences/ThemePage.js @@ -41,7 +41,7 @@ function ThemePage(props) { title={translate('themePage.theme')} shouldShowBackButton onBackButtonPress={() => Navigation.goBack()} - onCloseButtonPress={() => Navigation.dismissModal(true)} + onCloseButtonPress={() => Navigation.dismissModal()} /> {translate('themePage.chooseThemeBelowOrSync')} diff --git a/src/pages/tasks/TaskAssigneeSelectorModal.js b/src/pages/tasks/TaskAssigneeSelectorModal.js index 6ab37b1196b9..f3627a9bd04d 100644 --- a/src/pages/tasks/TaskAssigneeSelectorModal.js +++ b/src/pages/tasks/TaskAssigneeSelectorModal.js @@ -139,7 +139,7 @@ function TaskAssigneeSelectorModal(props) { if (report && !ReportUtils.isTaskReport(report)) { Navigation.isNavigationReady().then(() => { - Navigation.dismissModalWithReportID(report.reportID); + Navigation.dismissModal(report.reportID); }); } diff --git a/src/pages/tasks/TaskDescriptionPage.js b/src/pages/tasks/TaskDescriptionPage.js index bc2ade3aad0a..3a6999d4408a 100644 --- a/src/pages/tasks/TaskDescriptionPage.js +++ b/src/pages/tasks/TaskDescriptionPage.js @@ -60,14 +60,14 @@ function TaskDescriptionPage(props) { Task.editTask(props.report, {description: values.description}); } - Navigation.dismissModalWithReportID(props.report.reportID); + Navigation.dismissModal(props.report.reportID); }, [props], ); if (!ReportUtils.isTaskReport(props.report)) { Navigation.isNavigationReady().then(() => { - Navigation.dismissModalWithReportID(props.report.reportID); + Navigation.dismissModal(props.report.reportID); }); } const inputRef = useRef(null); diff --git a/src/pages/tasks/TaskTitlePage.js b/src/pages/tasks/TaskTitlePage.js index 351540b64e31..9b393a8a2374 100644 --- a/src/pages/tasks/TaskTitlePage.js +++ b/src/pages/tasks/TaskTitlePage.js @@ -66,14 +66,14 @@ function TaskTitlePage(props) { Task.editTask(props.report, {title: values.title}); } - Navigation.dismissModalWithReportID(props.report.reportID); + Navigation.dismissModal(props.report.reportID); }, [props], ); if (!ReportUtils.isTaskReport(props.report)) { Navigation.isNavigationReady().then(() => { - Navigation.dismissModalWithReportID(props.report.reportID); + Navigation.dismissModal(props.report.reportID); }); } diff --git a/src/pages/workspace/WorkspaceNewRoomPage.js b/src/pages/workspace/WorkspaceNewRoomPage.js index e3068ffb1de8..b616b519ff32 100644 --- a/src/pages/workspace/WorkspaceNewRoomPage.js +++ b/src/pages/workspace/WorkspaceNewRoomPage.js @@ -175,7 +175,7 @@ function WorkspaceNewRoomPage(props) { if (!(((wasLoading && !props.formState.isLoading) || (isOffline && props.formState.isLoading)) && _.isEmpty(props.formState.errorFields))) { return; } - Navigation.dismissModalWithReportID(newRoomReportID); + Navigation.dismissModal(newRoomReportID); // eslint-disable-next-line react-hooks/exhaustive-deps -- we just want this to update on changing the form State }, [props.formState]); diff --git a/src/pages/workspace/WorkspaceOverviewPage.js b/src/pages/workspace/WorkspaceOverviewPage.js index 7115e1092384..dd3945136c47 100644 --- a/src/pages/workspace/WorkspaceOverviewPage.js +++ b/src/pages/workspace/WorkspaceOverviewPage.js @@ -70,6 +70,7 @@ function WorkspaceOverviewPage({policy, currencyList, route}) { shouldShowLoading={false} shouldUseScrollView shouldShowOfflineIndicatorInWideScreen + shouldShowNonAdmin > {(hasVBA) => ( <> diff --git a/src/pages/workspace/WorkspacePageWithSections.tsx b/src/pages/workspace/WorkspacePageWithSections.tsx index 605eed9f64b5..27a27766136a 100644 --- a/src/pages/workspace/WorkspacePageWithSections.tsx +++ b/src/pages/workspace/WorkspacePageWithSections.tsx @@ -62,8 +62,14 @@ type WorkspacePageWithSectionsProps = WithPolicyAndFullscreenLoadingProps & /** Option to show the loading page while the API is calling */ shouldShowLoading?: boolean; + /** Should show the back button. It is used when in RHP. */ + shouldShowBackButton?: boolean; + shouldShowOfflineIndicatorInWideScreen?: boolean; + /** Whether to show this page to non admin policy members */ + shouldShowNonAdmin?: boolean; + /** Policy values needed in the component */ policy: OnyxEntry; }; @@ -88,9 +94,11 @@ function WorkspacePageWithSections({ route, shouldUseScrollView = false, shouldSkipVBBACall = false, + shouldShowBackButton = false, user, shouldShowLoading = true, shouldShowOfflineIndicatorInWideScreen = false, + shouldShowNonAdmin = false, }: WorkspacePageWithSectionsProps) { const styles = useThemeStyles(); useNetwork({onReconnect: () => fetchData(shouldSkipVBBACall)}); @@ -125,9 +133,9 @@ function WorkspacePageWithSections({ return true; } - return (!isEmptyObject(policy) && !PolicyUtils.isPolicyAdmin(policy)) || PolicyUtils.isPendingDeletePolicy(policy); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [policy]); + return (!isEmptyObject(policy) && !PolicyUtils.isPolicyAdmin(policy) && !shouldShowNonAdmin) || PolicyUtils.isPendingDeletePolicy(policy); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [policy, shouldShowNonAdmin]); return ( Navigation.goBack(backButtonRoute ?? ROUTES.WORKSPACE_INITIAL.getRoute(policyID))} /> {(isLoading || firstRender.current) && shouldShowLoading ? ( diff --git a/src/pages/workspace/WorkspacesListPage.tsx b/src/pages/workspace/WorkspacesListPage.tsx index 4bd86de4001b..9442ffafa862 100755 --- a/src/pages/workspace/WorkspacesListPage.tsx +++ b/src/pages/workspace/WorkspacesListPage.tsx @@ -25,6 +25,7 @@ import useWindowDimensions from '@hooks/useWindowDimensions'; import Navigation from '@libs/Navigation/Navigation'; import * as PolicyUtils from '@libs/PolicyUtils'; import * as ReportUtils from '@libs/ReportUtils'; +import type {AvatarSource} from '@libs/UserUtils'; import * as App from '@userActions/App'; import * as Policy from '@userActions/Policy'; import CONST from '@src/CONST'; @@ -38,10 +39,11 @@ import withPolicyAndFullscreenLoading from './withPolicyAndFullscreenLoading'; import type {WithPolicyAndFullscreenLoadingProps} from './withPolicyAndFullscreenLoading'; import WorkspacesListRow from './WorkspacesListRow'; -type WorkspaceItem = Required> & +type WorkspaceItem = Required> & Pick & Pick & Pick & { + icon: AvatarSource; action: () => void; dismissError: () => void; iconType?: ValueOf; diff --git a/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js b/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js index 4a37c79125ac..2ed09212233c 100644 --- a/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js +++ b/src/pages/workspace/reimburse/WorkspaceRateAndUnitPage.js @@ -102,6 +102,7 @@ function WorkspaceRateAndUnitPage(props) { guidesCallTaskID={CONST.GUIDES_CALL_TASK_IDS.WORKSPACE_REIMBURSE} shouldSkipVBBACall shouldShowLoading={false} + shouldShowBackButton > {() => ( paddingHorizontal: 24, backgroundColor: theme.hoverComponentBG, borderRadius: variables.componentBorderRadiusRounded, + justifyContent: 'center', }, searchContainerHovered: { @@ -3703,10 +3704,6 @@ const styles = (theme: ThemeColors) => ...flex.alignItemsCenter, }, - shareCodePage: { - paddingHorizontal: 38.5, - }, - shareCodeContainer: { width: '100%', alignItems: 'center', diff --git a/tests/actions/IOUTest.js b/tests/actions/IOUTest.js index cc5088ebd4c9..92b39fc3ac50 100644 --- a/tests/actions/IOUTest.js +++ b/tests/actions/IOUTest.js @@ -24,7 +24,6 @@ jest.mock('../../src/libs/Navigation/Navigation', () => ({ navigate: jest.fn(), dismissModal: jest.fn(), dismissModalWithReport: jest.fn(), - dismissModalWithReportID: jest.fn(), goBack: jest.fn(), }));