diff --git a/src/components/SelectionList/UserListItem.tsx b/src/components/SelectionList/UserListItem.tsx index a517a9f1ca15..8fe9518c7d90 100644 --- a/src/components/SelectionList/UserListItem.tsx +++ b/src/components/SelectionList/UserListItem.tsx @@ -30,6 +30,7 @@ function UserListItem({ rightHandSideComponent, onFocus, shouldSyncFocus, + pressableStyle, }: UserListItemProps) { const styles = useThemeStyles(); const theme = useTheme(); @@ -63,6 +64,7 @@ function UserListItem({ rightHandSideComponent={rightHandSideComponent} errors={item.errors} pendingAction={item.pendingAction} + pressableStyle={pressableStyle} FooterComponent={ item.invitedSecondaryLogin ? ( diff --git a/src/pages/WorkspaceSwitcherPage/WorkspacesSectionHeader.tsx b/src/pages/WorkspaceSwitcherPage/WorkspacesSectionHeader.tsx index 85e13ba4c0a5..36e24036d365 100644 --- a/src/pages/WorkspaceSwitcherPage/WorkspacesSectionHeader.tsx +++ b/src/pages/WorkspaceSwitcherPage/WorkspacesSectionHeader.tsx @@ -19,7 +19,7 @@ function WorkspacesSectionHeader() { const {translate} = useLocalize(); return ( - + ; function WorkspaceSwitcherPage() { + const styles = useThemeStyles(); + const theme = useTheme(); const {isOffline} = useNetwork(); const [searchTerm, debouncedSearchTerm, setSearchTerm] = useDebouncedState(''); const {translate} = useLocalize(); @@ -39,7 +45,7 @@ function WorkspaceSwitcherPage() { const [reports] = useOnyx(ONYXKEYS.COLLECTION.REPORT); const [reportActions] = useOnyx(ONYXKEYS.COLLECTION.REPORT_ACTIONS); - const [policies] = useOnyx(ONYXKEYS.COLLECTION.POLICY); + const [policies, fetchStatus] = useOnyx(ONYXKEYS.COLLECTION.POLICY); const brickRoadsForPolicies = useMemo(() => getWorkspacesBrickRoads(reports, policies, reportActions), [reports, policies, reportActions]); const unreadStatusesForPolicies = useMemo(() => getWorkspacesUnreadStatuses(reports), [reports]); @@ -130,54 +136,67 @@ function WorkspaceSwitcherPage() { const sections = useMemo(() => { const options: Array> = [ { - title: translate('workspace.switcher.everythingSection'), + data: filteredAndSortedUserWorkspaces, shouldShow: true, - indexOffset: 0, - data: [ - { - text: CONST.WORKSPACE_SWITCHER.NAME, - icons: [{source: Expensicons.ExpensifyAppIcon, name: CONST.WORKSPACE_SWITCHER.NAME, type: CONST.ICON_TYPE_AVATAR}], - brickRoadIndicator: getIndicatorTypeForPolicy(undefined), - isSelected: activeWorkspaceID === undefined, - keyForList: CONST.WORKSPACE_SWITCHER.NAME, - }, - ], + indexOffset: 1, }, ]; - options.push({ - CustomSectionHeader: WorkspacesSectionHeader, - data: filteredAndSortedUserWorkspaces, - shouldShow: true, - indexOffset: 1, - }); return options; - }, [activeWorkspaceID, filteredAndSortedUserWorkspaces, getIndicatorTypeForPolicy, translate]); + }, [filteredAndSortedUserWorkspaces]); const headerMessage = filteredAndSortedUserWorkspaces.length === 0 && usersWorkspaces.length ? translate('common.noResultsFound') : ''; const shouldShowCreateWorkspace = usersWorkspaces.length === 0; + const defaultPolicy = { + text: CONST.WORKSPACE_SWITCHER.NAME, + icons: [{source: Expensicons.ExpensifyAppIcon, name: CONST.WORKSPACE_SWITCHER.NAME, type: CONST.ICON_TYPE_AVATAR}], + brickRoadIndicator: getIndicatorTypeForPolicy(undefined), + keyForList: CONST.WORKSPACE_SWITCHER.NAME, + isSelected: activeWorkspaceID === undefined, + }; + return ( - - - ListItem={UserListItem} - sections={sections} - onSelectRow={selectPolicy} - shouldDebounceRowSelect - textInputLabel={usersWorkspaces.length >= CONST.WORKSPACE_SWITCHER.MINIMUM_WORKSPACES_TO_SHOW_SEARCH ? translate('common.search') : undefined} - textInputValue={searchTerm} - onChangeText={setSearchTerm} - headerMessage={headerMessage} - listFooterContent={shouldShowCreateWorkspace ? WorkspaceCardCreateAWorkspaceInstance : null} - initiallyFocusedOptionKey={activeWorkspaceID ?? CONST.WORKSPACE_SWITCHER.NAME} - showLoadingPlaceholder - /> + {({didScreenTransitionEnd}) => ( + <> + + + + {translate('workspace.switcher.everythingSection')} + + + selectPolicy(defaultPolicy)} + pressableStyle={styles.flexRow} + shouldSyncFocus={false} + /> + + + ListItem={UserListItem} + sections={sections} + onSelectRow={selectPolicy} + textInputLabel={usersWorkspaces.length >= CONST.WORKSPACE_SWITCHER.MINIMUM_WORKSPACES_TO_SHOW_SEARCH ? translate('common.search') : undefined} + textInputValue={searchTerm} + onChangeText={setSearchTerm} + headerMessage={headerMessage} + listFooterContent={shouldShowCreateWorkspace ? WorkspaceCardCreateAWorkspaceInstance : null} + initiallyFocusedOptionKey={activeWorkspaceID ?? CONST.WORKSPACE_SWITCHER.NAME} + showLoadingPlaceholder={fetchStatus.status === 'loading' || !didScreenTransitionEnd} + /> + + )} ); }