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
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
multiDexEnabled rootProject.ext.multiDexEnabled
versionCode 1001017903
versionName "1.1.79-3"
versionCode 1001017905
versionName "1.1.79-5"
}
splits {
abi {
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>1.1.79.3</string>
<string>1.1.79.5</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/NewExpensifyTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.1.79.3</string>
<string>1.1.79.5</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "new.expensify",
"version": "1.1.79-3",
"version": "1.1.79-5",
"author": "Expensify, Inc.",
"homepage": "https://new.expensify.com",
"description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",
Expand Down
24 changes: 5 additions & 19 deletions src/libs/Navigation/AppNavigator/MainDrawerNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import ReportScreen from '../../../pages/home/ReportScreen';
import SidebarScreen from '../../../pages/home/sidebar/SidebarScreen';
import BaseDrawerNavigator from './BaseDrawerNavigator';
import * as ReportUtils from '../../ReportUtils';
import * as PolicyUtils from '../../PolicyUtils';
import CONST from '../../../CONST';

const propTypes = {
/** Available reports that would be displayed in this navigator */
Expand Down Expand Up @@ -44,32 +42,20 @@ const defaultProps = {
* Get the most recently accessed report for the user
*
* @param {Object} reports
* @param {String[]} [reportTypesToIgnore]
* @param {Boolean} [ignoreDefaultRooms]
* @param {Object} policies
* @returns {Object}
*/
const getInitialReportScreenParams = (reports, reportTypesToIgnore) => {
const last = ReportUtils.findLastAccessedReport(reports, reportTypesToIgnore);
const getInitialReportScreenParams = (reports, ignoreDefaultRooms, policies) => {
const last = ReportUtils.findLastAccessedReport(reports, ignoreDefaultRooms, policies);

// Fallback to empty if for some reason reportID cannot be derived - prevents the app from crashing
const reportID = lodashGet(last, 'reportID', '');
return {reportID: String(reportID)};
};

const MainDrawerNavigator = (props) => {
// If one is a member of a free policy, then they are allowed to see the Policy default rooms.
// For everyone else, one must be on the beta to see a default room.
let reportTypesToIgnore = [];
const isMemberOfFreePolicy = PolicyUtils.isMemberOfFreePolicy(props.policies);
if (isMemberOfFreePolicy && !Permissions.canUseDefaultRooms(props.betas)) {
reportTypesToIgnore = [CONST.REPORT.CHAT_TYPE.DOMAIN_ALL];
} else if (!Permissions.canUseDefaultRooms(props.betas)) {
reportTypesToIgnore = [
CONST.REPORT.CHAT_TYPE.POLICY_ADMINS,
CONST.REPORT.CHAT_TYPE.POLICY_ANNOUNCE,
CONST.REPORT.CHAT_TYPE.DOMAIN_ALL,
];
}
const initialParams = getInitialReportScreenParams(props.reports, reportTypesToIgnore);
const initialParams = getInitialReportScreenParams(props.reports, !Permissions.canUseDefaultRooms(props.betas), props.policies);

// Wait until reports are fetched and there is a reportID in initialParams
if (!initialParams.reportID) {
Expand Down
11 changes: 2 additions & 9 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import * as ReportUtils from './ReportUtils';
import * as Localize from './Localize';
import Permissions from './Permissions';
import * as CollectionUtils from './CollectionUtils';
import * as PolicyUtils from './PolicyUtils';

/**
* OptionsListUtils is used to build a list options passed to the OptionsList component. Several different UI views can
Expand Down Expand Up @@ -441,14 +440,8 @@ function getOptions(reports, personalDetails, activeReportID, {
return;
}

// If one is a member of a free policy, then they are allowed to see the Policy default rooms.
// For everyone else, one must be on the beta to see a default room.
const isMemberOfFreePolicy = PolicyUtils.isMemberOfFreePolicy(policies);
if (isMemberOfFreePolicy && !Permissions.canUseDefaultRooms(betas)) {
if (ReportUtils.isDomainRoom(report)) {
return;
}
} else if (ReportUtils.isDefaultRoom(report) && !Permissions.canUseDefaultRooms(betas)) {
// We let Free Plan default rooms to be shown in the App - it's the one exception to the beta, otherwise do not show policy rooms in product
if (ReportUtils.isDefaultRoom(report) && !Permissions.canUseDefaultRooms(betas) && ReportUtils.getPolicyType(report, policies) !== CONST.POLICY.TYPE.FREE) {
return;
}

Expand Down
30 changes: 0 additions & 30 deletions src/libs/PolicyUtils.js

This file was deleted.

22 changes: 17 additions & 5 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,30 @@ function isChatRoom(report) {
return isUserCreatedPolicyRoom(report) || isDefaultRoom(report);
}

/**
* Get the policy type from a given report
* @param {Object} report
* @param {String} report.policyID
* @param {Object} policies must have Onyxkey prefix (i.e 'policy_') for keys
* @returns {String}
*/
function getPolicyType(report, policies) {
return lodashGet(policies, [`${ONYXKEYS.COLLECTION.POLICY}${report.policyID}`, 'type'], '');
}

/**
* Given a collection of reports returns the most recently accessed one
*
* @param {Record<String, {lastVisitedTimestamp, reportID}>|Array<{lastVisitedTimestamp, reportID}>} reports
* @param {String[]} [reportTypesToIgnore]
* @param {Boolean} [ignoreDefaultRooms]
* @param {Object} policies
* @returns {Object}
*/
function findLastAccessedReport(reports, reportTypesToIgnore) {
function findLastAccessedReport(reports, ignoreDefaultRooms, policies) {
let sortedReports = sortReportsByLastVisited(reports);

if (reportTypesToIgnore) {
sortedReports = _.filter(sortedReports, report => !_.contains(reportTypesToIgnore, lodashGet(report, ['chatType'], '')));
if (ignoreDefaultRooms) {
sortedReports = _.filter(sortedReports, report => !isDefaultRoom(report) || getPolicyType(report, policies) === CONST.POLICY.TYPE.FREE);
}

return _.last(sortedReports);
Expand Down Expand Up @@ -512,11 +524,11 @@ export {
isDefaultRoom,
isAdminRoom,
isAnnounceRoom,
isDomainRoom,
isUserCreatedPolicyRoom,
isChatRoom,
getChatRoomSubtitle,
getPolicyName,
getPolicyType,
isArchivedRoom,
isConciergeChatReport,
hasExpensifyEmails,
Expand Down
13 changes: 13 additions & 0 deletions src/libs/actions/Policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,18 @@ function loadFullPolicy(policyID) {
});
}

/**
* Is the user an admin of a free policy (aka workspace)?
*
* @param {Array} policies
* @returns {Boolean}
*/
function isAdminOfFreePolicy(policies) {
return _.some(policies, policy => policy
&& policy.type === CONST.POLICY.TYPE.FREE
&& policy.role === CONST.POLICY.ROLE.ADMIN);
}

/**
* Remove the passed members from the policy employeeList
*
Expand Down Expand Up @@ -538,6 +550,7 @@ export {
loadFullPolicy,
removeMembers,
invite,
isAdminOfFreePolicy,
create,
uploadAvatar,
update,
Expand Down
4 changes: 2 additions & 2 deletions src/libs/actions/Welcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import lodashGet from 'lodash/get';
import Navigation from '../Navigation/Navigation';
import * as ReportUtils from '../ReportUtils';
import ROUTES from '../../ROUTES';
import * as Policy from './Policy';
import ONYXKEYS from '../../ONYXKEYS';
import NameValuePair from './NameValuePair';
import CONST from '../../CONST';
import SCREENS from '../../SCREENS';
import * as PolicyUtils from '../PolicyUtils';

let resolveIsReadyPromise;
let isReadyPromise = new Promise((resolve) => {
Expand Down Expand Up @@ -130,7 +130,7 @@ function show({routes, showCreateMenu}) {

// If user is not already an admin of a free policy and we are not navigating them to their workspace or creating a new workspace via workspace/new then
// we will show the create menu.
if (!PolicyUtils.isAdminOfFreePolicy(allPolicies) && !isDisplayingWorkspaceRoute) {
if (!Policy.isAdminOfFreePolicy(allPolicies) && !isDisplayingWorkspaceRoute) {
showCreateMenu();
}
});
Expand Down
13 changes: 4 additions & 9 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndica
import reportActionPropTypes from './report/reportActionPropTypes';
import ArchivedReportFooter from '../../components/ArchivedReportFooter';
import toggleReportActionComposeView from '../../libs/toggleReportActionComposeView';
import * as PolicyUtils from '../../libs/PolicyUtils';

const propTypes = {
/** Navigation route context info provided by react navigation */
Expand Down Expand Up @@ -195,14 +194,10 @@ class ReportScreen extends React.Component {
return null;
}

// If one is a member of a free policy, then they are allowed to see the Policy default rooms.
// For everyone else, one must be on the beta to see a default room.
const isMemberOfFreePolicy = PolicyUtils.isMemberOfFreePolicy(this.props.policies);
if (isMemberOfFreePolicy && !Permissions.canUseDefaultRooms(this.props.betas)) {
if (ReportUtils.isDomainRoom(this.props.report)) {
return null;
}
} else if (ReportUtils.isDefaultRoom(this.props.report) && !Permissions.canUseDefaultRooms(this.props.betas)) {
// We let Free Plan default rooms to be shown in the App - it's the one exception to the beta, otherwise do not show policy rooms in product
if (!Permissions.canUseDefaultRooms(this.props.betas)
&& ReportUtils.isDefaultRoom(this.props.report)
&& ReportUtils.getPolicyType(this.props.report, this.props.policies) !== CONST.POLICY.TYPE.FREE) {
return null;
}

Expand Down
3 changes: 1 addition & 2 deletions src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import * as Policy from '../../../../libs/actions/Policy';
import Performance from '../../../../libs/Performance';
import * as Welcome from '../../../../libs/actions/Welcome';
import {sidebarPropTypes, sidebarDefaultProps} from './sidebarPropTypes';
import * as PolicyUtils from '../../../../libs/PolicyUtils';

const propTypes = {

Expand Down Expand Up @@ -164,7 +163,7 @@ class BaseSidebarScreen extends Component {
onSelected: () => Navigation.navigate(ROUTES.IOU_BILL),
},
] : []),
...(!this.props.isCreatingWorkspace && !PolicyUtils.isAdminOfFreePolicy(this.props.allPolicies) ? [
...(!this.props.isCreatingWorkspace && !Policy.isAdminOfFreePolicy(this.props.allPolicies) ? [
{
icon: Expensicons.NewWorkspace,
iconWidth: 46,
Expand Down