Skip to content
Merged
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
1 change: 1 addition & 0 deletions src/libs/actions/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ function create(name = '') {
}
res = response;

// We are awaiting this merge so that we can guarantee our policy is available to any React components connected to the policies collection before we navigate to a new route.
return Onyx.merge(`${ONYXKEYS.COLLECTION.POLICY}${response.policyID}`, {
employeeList: getSimplifiedEmployeeList(response.policy.employeeList),
id: response.policyID,
Expand Down
16 changes: 15 additions & 1 deletion src/pages/home/sidebar/SidebarScreen.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import _ from 'underscore';
import lodashGet from 'lodash/get';
import React, {Component} from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import PropTypes from 'prop-types';
import {withNavigation} from '@react-navigation/compat';
import styles from '../../../styles/styles';
import SidebarLinks from './SidebarLinks';
import PopoverMenu from '../../../components/PopoverMenu';
Expand Down Expand Up @@ -61,7 +64,17 @@ class SidebarScreen extends Component {
// This is a short-term workaround, see this issue for updates on a long-term solution: https://github.com/Expensify/App/issues/5296
setTimeout(() => {
if (this.props.isFirstTimeNewExpensifyUser) {
this.toggleCreateMenu();
// 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
// create menu right now.
const routes = lodashGet(this.props.navigation.getState(), 'routes', []);
const topRouteName = lodashGet(_.last(routes), 'name', '');
const isDisplayingWorkspaceRoute = topRouteName.toLowerCase().includes('workspace');

// 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
// not need to create a workspace.
if (!isAdminOfFreePolicy(this.props.allPolicies) && !isDisplayingWorkspaceRoute) {
this.toggleCreateMenu();
}

// Set the NVP back to false so we don't automatically open the menu again
// Note: this may need to be moved if this NVP is used for anything else later
Expand Down Expand Up @@ -180,6 +193,7 @@ class SidebarScreen extends Component {

SidebarScreen.propTypes = propTypes;
export default compose(
withNavigation,
withLocalize,
withWindowDimensions,
withOnyx({
Expand Down