|
| 1 | +import _ from 'underscore'; |
| 2 | +import lodashGet from 'lodash/get'; |
1 | 3 | import React, {Component} from 'react';
|
2 | 4 | import {View} from 'react-native';
|
3 | 5 | import {withOnyx} from 'react-native-onyx';
|
4 | 6 | import PropTypes from 'prop-types';
|
| 7 | +import {withNavigation} from '@react-navigation/compat'; |
5 | 8 | import styles from '../../../styles/styles';
|
6 | 9 | import SidebarLinks from './SidebarLinks';
|
7 | 10 | import PopoverMenu from '../../../components/PopoverMenu';
|
@@ -61,7 +64,17 @@ class SidebarScreen extends Component {
|
61 | 64 | // This is a short-term workaround, see this issue for updates on a long-term solution: https://github.com/Expensify/App/issues/5296
|
62 | 65 | setTimeout(() => {
|
63 | 66 | if (this.props.isFirstTimeNewExpensifyUser) {
|
64 |
| - this.toggleCreateMenu(); |
| 67 | + // If we are rendering the SidebarScreen at the same time as a workspace route that means we've already created a workspace via workspace/new and should not open the global |
| 68 | + // create menu right now. |
| 69 | + const routes = lodashGet(this.props.navigation.getState(), 'routes', []); |
| 70 | + const topRouteName = lodashGet(_.last(routes), 'name', ''); |
| 71 | + const isDisplayingWorkspaceRoute = topRouteName.toLowerCase().includes('workspace'); |
| 72 | + |
| 73 | + // It's also possible that we already have a workspace policy. In either case we will not toggle the menu but do still want to set the NVP in this case since the user does |
| 74 | + // not need to create a workspace. |
| 75 | + if (!isAdminOfFreePolicy(this.props.allPolicies) && !isDisplayingWorkspaceRoute) { |
| 76 | + this.toggleCreateMenu(); |
| 77 | + } |
65 | 78 |
|
66 | 79 | // Set the NVP back to false so we don't automatically open the menu again
|
67 | 80 | // Note: this may need to be moved if this NVP is used for anything else later
|
@@ -180,6 +193,7 @@ class SidebarScreen extends Component {
|
180 | 193 |
|
181 | 194 | SidebarScreen.propTypes = propTypes;
|
182 | 195 | export default compose(
|
| 196 | + withNavigation, |
183 | 197 | withLocalize,
|
184 | 198 | withWindowDimensions,
|
185 | 199 | withOnyx({
|
|
0 commit comments