From 7e6f2bd74a4462b3c8cfa4074e41aa484343dcf3 Mon Sep 17 00:00:00 2001 From: OSBotify <76178356+OSBotify@users.noreply.github.com> Date: Thu, 30 Jun 2022 08:54:39 -0700 Subject: [PATCH 1/2] Merge pull request #9636 from Expensify/version-BUILD-d9ceb25fae3a21db1791ab38e37f9eb6e0f44c68 Update version to 1.1.79-5 on main (cherry picked from commit 837d8332f66ca17e963824c010d4fa5e483c35d0) --- android/app/build.gradle | 4 ++-- ios/NewExpensify/Info.plist | 2 +- ios/NewExpensifyTests/Info.plist | 2 +- package-lock.json | 2 +- package.json | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 496e523991db..7b035ccb2c22 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -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 { diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist index f70b8da703df..1b007001f840 100644 --- a/ios/NewExpensify/Info.plist +++ b/ios/NewExpensify/Info.plist @@ -30,7 +30,7 @@ CFBundleVersion - 1.1.79.3 + 1.1.79.5 ITSAppUsesNonExemptEncryption LSApplicationQueriesSchemes diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist index 814cd083c9a6..ed9fbfd99da1 100644 --- a/ios/NewExpensifyTests/Info.plist +++ b/ios/NewExpensifyTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 1.1.79.3 + 1.1.79.5 diff --git a/package-lock.json b/package-lock.json index 7173d498089c..1fbd583bb2fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "new.expensify", - "version": "1.1.79-3", + "version": "1.1.79-5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7e915803aacf..d07d2f8d6c35 100644 --- a/package.json +++ b/package.json @@ -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.", From 305712eb09470577ced9598646dc5fa18c3c8abe Mon Sep 17 00:00:00 2001 From: Monil Bhavsar Date: Thu, 30 Jun 2022 10:31:57 +0530 Subject: [PATCH 2/2] Merge pull request #9632 from Expensify/revert-9460-yuwen-freePolicyDefaultRooms Allow free policies to have their default rooms be shown (cherry picked from commit 02f433979a7d22baa7d544ba5b6e236d77e7e0e3) --- .../AppNavigator/MainDrawerNavigator.js | 24 ++++----------- src/libs/OptionsListUtils.js | 11 ++----- src/libs/PolicyUtils.js | 30 ------------------- src/libs/ReportUtils.js | 22 ++++++++++---- src/libs/actions/Policy.js | 13 ++++++++ src/libs/actions/Welcome.js | 4 +-- src/pages/home/ReportScreen.js | 13 +++----- .../SidebarScreen/BaseSidebarScreen.js | 3 +- 8 files changed, 44 insertions(+), 76 deletions(-) delete mode 100644 src/libs/PolicyUtils.js diff --git a/src/libs/Navigation/AppNavigator/MainDrawerNavigator.js b/src/libs/Navigation/AppNavigator/MainDrawerNavigator.js index 3f966d71e6bb..cc6ef419e5ec 100644 --- a/src/libs/Navigation/AppNavigator/MainDrawerNavigator.js +++ b/src/libs/Navigation/AppNavigator/MainDrawerNavigator.js @@ -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 */ @@ -44,11 +42,12 @@ 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', ''); @@ -56,20 +55,7 @@ const getInitialReportScreenParams = (reports, reportTypesToIgnore) => { }; 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) { diff --git a/src/libs/OptionsListUtils.js b/src/libs/OptionsListUtils.js index a3c39f4235be..53ae93cf8b74 100644 --- a/src/libs/OptionsListUtils.js +++ b/src/libs/OptionsListUtils.js @@ -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 @@ -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; } diff --git a/src/libs/PolicyUtils.js b/src/libs/PolicyUtils.js deleted file mode 100644 index d225fd1982b7..000000000000 --- a/src/libs/PolicyUtils.js +++ /dev/null @@ -1,30 +0,0 @@ -import _ from 'underscore'; -import CONST from '../CONST'; - -/** - * 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); -} - -/** - * Is the user a member of a free policy (aka workspace)? - * - * @param {Array} policies - * @returns {Boolean} - */ -function isMemberOfFreePolicy(policies) { - return _.some(policies, policy => policy - && policy.type === CONST.POLICY.TYPE.FREE); -} - -export { - isAdminOfFreePolicy, - isMemberOfFreePolicy, -}; diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 1547c358b497..3a2224d86b21 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -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|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); @@ -512,11 +524,11 @@ export { isDefaultRoom, isAdminRoom, isAnnounceRoom, - isDomainRoom, isUserCreatedPolicyRoom, isChatRoom, getChatRoomSubtitle, getPolicyName, + getPolicyType, isArchivedRoom, isConciergeChatReport, hasExpensifyEmails, diff --git a/src/libs/actions/Policy.js b/src/libs/actions/Policy.js index ab522704268a..aa037a5cf692 100644 --- a/src/libs/actions/Policy.js +++ b/src/libs/actions/Policy.js @@ -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 * @@ -538,6 +550,7 @@ export { loadFullPolicy, removeMembers, invite, + isAdminOfFreePolicy, create, uploadAvatar, update, diff --git a/src/libs/actions/Welcome.js b/src/libs/actions/Welcome.js index 0d2eeadff248..41c559093941 100644 --- a/src/libs/actions/Welcome.js +++ b/src/libs/actions/Welcome.js @@ -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) => { @@ -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(); } }); diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 4b4faa4d7013..7bb33fe59abc 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -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 */ @@ -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; } diff --git a/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js b/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js index f1b77faf5736..a939c5bf4e19 100644 --- a/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js +++ b/src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js @@ -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 = { @@ -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,