Skip to content

Commit 4f412db

Browse files
authored
Merge pull request #24579 from Expensify/beaman-removePolicyExpenseChatBeta
Remove policy expense chat beta
2 parents 79ea923 + 3352cc8 commit 4f412db

10 files changed

+45
-102
lines changed

src/CONST.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ const CONST = {
231231
INTERNATIONALIZATION: 'internationalization',
232232
IOU_SEND: 'sendMoney',
233233
POLICY_ROOMS: 'policyRooms',
234-
POLICY_EXPENSE_CHAT: 'policyExpenseChat',
235234
PASSWORDLESS: 'passwordless',
236235
TASKS: 'tasks',
237236
THREADS: 'threads',

src/libs/Permissions.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,6 @@ function canUsePolicyRooms(betas) {
7070
return _.contains(betas, CONST.BETAS.POLICY_ROOMS) || canUseAllBetas(betas);
7171
}
7272

73-
/**
74-
* @param {Array<String>} betas
75-
* @returns {Boolean}
76-
*/
77-
function canUsePolicyExpenseChat(betas) {
78-
return _.contains(betas, CONST.BETAS.POLICY_EXPENSE_CHAT) || canUseAllBetas(betas);
79-
}
80-
8173
/**
8274
* @param {Array<String>} betas
8375
* @returns {Boolean}
@@ -126,7 +118,6 @@ export default {
126118
canUseWallet,
127119
canUseCommentLinking,
128120
canUsePolicyRooms,
129-
canUsePolicyExpenseChat,
130121
canUseTasks,
131122
canUseScanReceipts,
132123
canUseCustomStatus,

src/libs/ReportUtils.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2638,11 +2638,6 @@ function shouldReportBeInOptionList(report, currentReportId, isInGSDMode, betas,
26382638
return true;
26392639
}
26402640

2641-
// Exclude policy expense chats if the user isn't in the policy expense chat beta
2642-
if (isPolicyExpenseChat(report) && !Permissions.canUsePolicyExpenseChat(betas)) {
2643-
return false;
2644-
}
2645-
26462641
// Hide chats between two users that haven't been commented on from the LNH
26472642
if (excludeEmptyChats && isEmptyChat && isChatReport(report) && !isChatRoom(report) && !isPolicyExpenseChat(report)) {
26482643
return false;

src/libs/__mocks__/Permissions.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@ export default {
1212
...jest.requireActual('../Permissions'),
1313
canUseDefaultRooms: (betas) => _.contains(betas, CONST.BETAS.DEFAULT_ROOMS),
1414
canUsePolicyRooms: (betas) => _.contains(betas, CONST.BETAS.POLICY_ROOMS),
15-
canUsePolicyExpenseChat: (betas) => _.contains(betas, CONST.BETAS.POLICY_EXPENSE_CHAT),
1615
canUseIOUSend: (betas) => _.contains(betas, CONST.BETAS.IOU_SEND),
1716
};

src/libs/actions/Policy.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import * as ErrorUtils from '../ErrorUtils';
1313
import * as ReportUtils from '../ReportUtils';
1414
import * as PersonalDetailsUtils from '../PersonalDetailsUtils';
1515
import Log from '../Log';
16-
import Permissions from '../Permissions';
1716

1817
const allPolicies = {};
1918
Onyx.connect({
@@ -234,22 +233,16 @@ function removeMembers(accountIDs, policyID) {
234233
*
235234
* @param {String} policyID
236235
* @param {Object} invitedEmailsToAccountIDs
237-
* @param {Array} betas
238236
* @returns {Object} - object with onyxSuccessData, onyxOptimisticData, and optimisticReportIDs (map login to reportID)
239237
*/
240-
function createPolicyExpenseChats(policyID, invitedEmailsToAccountIDs, betas) {
238+
function createPolicyExpenseChats(policyID, invitedEmailsToAccountIDs) {
241239
const workspaceMembersChats = {
242240
onyxSuccessData: [],
243241
onyxOptimisticData: [],
244242
onyxFailureData: [],
245243
reportCreationData: {},
246244
};
247245

248-
// If the user is not in the beta, we don't want to create any chats
249-
if (!Permissions.canUsePolicyExpenseChat(betas)) {
250-
return workspaceMembersChats;
251-
}
252-
253246
_.each(invitedEmailsToAccountIDs, (accountID, email) => {
254247
const cleanAccountID = Number(accountID);
255248
const login = OptionsListUtils.addSMSDomainIfPhoneNumber(email);
@@ -332,16 +325,15 @@ function createPolicyExpenseChats(policyID, invitedEmailsToAccountIDs, betas) {
332325
* @param {Object} invitedEmailsToAccountIDs
333326
* @param {String} welcomeNote
334327
* @param {String} policyID
335-
* @param {Array<String>} betas
336328
*/
337-
function addMembersToWorkspace(invitedEmailsToAccountIDs, welcomeNote, policyID, betas) {
329+
function addMembersToWorkspace(invitedEmailsToAccountIDs, welcomeNote, policyID) {
338330
const membersListKey = `${ONYXKEYS.COLLECTION.POLICY_MEMBERS}${policyID}`;
339331
const logins = _.map(_.keys(invitedEmailsToAccountIDs), (memberLogin) => OptionsListUtils.addSMSDomainIfPhoneNumber(memberLogin));
340332
const accountIDs = _.values(invitedEmailsToAccountIDs);
341333
const newPersonalDetailsOnyxData = PersonalDetailsUtils.getNewPersonalDetailsOnyxData(logins, accountIDs);
342334

343335
// create onyx data for policy expense chats for each new member
344-
const membersChats = createPolicyExpenseChats(policyID, invitedEmailsToAccountIDs, betas);
336+
const membersChats = createPolicyExpenseChats(policyID, invitedEmailsToAccountIDs);
345337

346338
const optimisticData = [
347339
{

src/pages/workspace/WorkspaceInviteMessagePage.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ const propTypes = {
4747
/** All of the personal details for everyone */
4848
allPersonalDetails: PropTypes.objectOf(personalDetailsPropTypes),
4949

50-
/** Beta features list */
51-
betas: PropTypes.arrayOf(PropTypes.string),
52-
5350
invitedEmailsToAccountIDsDraft: PropTypes.objectOf(PropTypes.number),
5451

5552
/** URL Route params */
@@ -68,7 +65,6 @@ const propTypes = {
6865
const defaultProps = {
6966
...policyDefaultProps,
7067
allPersonalDetails: {},
71-
betas: [],
7268
invitedEmailsToAccountIDsDraft: {},
7369
};
7470

@@ -123,7 +119,7 @@ class WorkspaceInviteMessagePage extends React.Component {
123119

124120
sendInvitation() {
125121
Keyboard.dismiss();
126-
Policy.addMembersToWorkspace(this.props.invitedEmailsToAccountIDsDraft, this.state.welcomeNote, this.props.route.params.policyID, this.props.betas);
122+
Policy.addMembersToWorkspace(this.props.invitedEmailsToAccountIDsDraft, this.state.welcomeNote, this.props.route.params.policyID);
127123
Policy.setWorkspaceInviteMembersDraft(this.props.route.params.policyID, {});
128124
// Pop the invite message page before navigating to the members page.
129125
Navigation.goBack();
@@ -248,9 +244,6 @@ export default compose(
248244
allPersonalDetails: {
249245
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
250246
},
251-
betas: {
252-
key: ONYXKEYS.BETAS,
253-
},
254247
invitedEmailsToAccountIDsDraft: {
255248
key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${route.params.policyID.toString()}`,
256249
},

tests/unit/OptionsListUtilsTest.js

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import _ from 'underscore';
22
import Onyx from 'react-native-onyx';
33
import * as OptionsListUtils from '../../src/libs/OptionsListUtils';
4+
import * as ReportUtils from '../../src/libs/ReportUtils';
45
import ONYXKEYS from '../../src/ONYXKEYS';
56
import waitForPromisesToResolve from '../utils/waitForPromisesToResolve';
67
import CONST from '../../src/CONST';
@@ -103,6 +104,10 @@ describe('OptionsListUtils', () => {
103104
oldPolicyName: "SHIELD's workspace",
104105
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
105106
isOwnPolicyExpenseChat: true,
107+
108+
// This indicates that the report is archived
109+
stateNum: 2,
110+
statusNum: 2,
106111
},
107112
};
108113

@@ -567,39 +572,57 @@ describe('OptionsListUtils', () => {
567572
});
568573

569574
it('getShareDestinationsOptions()', () => {
575+
// Filter current REPORTS as we do in the component, before getting share destination options
576+
const filteredReports = {};
577+
_.keys(REPORTS).forEach((reportKey) => {
578+
if (ReportUtils.shouldDisableWriteActions(REPORTS[reportKey]) || ReportUtils.isExpensifyOnlyParticipantInReport(REPORTS[reportKey])) {
579+
return;
580+
}
581+
filteredReports[reportKey] = REPORTS[reportKey];
582+
});
583+
570584
// When we pass an empty search value
571-
let results = OptionsListUtils.getShareDestinationOptions(REPORTS, PERSONAL_DETAILS, [], '');
585+
let results = OptionsListUtils.getShareDestinationOptions(filteredReports, PERSONAL_DETAILS, [], '');
572586

573587
// Then we should expect all the recent reports to show but exclude the archived rooms
574588
expect(results.recentReports.length).toBe(_.size(REPORTS) - 1);
575589

576590
// When we pass a search value that doesn't match the group chat name
577-
results = OptionsListUtils.getShareDestinationOptions(REPORTS, PERSONAL_DETAILS, [], 'mutants');
591+
results = OptionsListUtils.getShareDestinationOptions(filteredReports, PERSONAL_DETAILS, [], 'mutants');
578592

579593
// Then we should expect no recent reports to show
580594
expect(results.recentReports.length).toBe(0);
581595

582596
// When we pass a search value that matches the group chat name
583-
results = OptionsListUtils.getShareDestinationOptions(REPORTS, PERSONAL_DETAILS, [], 'Iron Man, Fantastic');
597+
results = OptionsListUtils.getShareDestinationOptions(filteredReports, PERSONAL_DETAILS, [], 'Iron Man, Fantastic');
584598

585599
// Then we should expect the group chat to show along with the contacts matching the search
586600
expect(results.recentReports.length).toBe(1);
587601

602+
// Filter current REPORTS_WITH_WORKSPACE_ROOMS as we do in the component, before getting share destination options
603+
const filteredReportsWithWorkspaceRooms = {};
604+
_.keys(REPORTS_WITH_WORKSPACE_ROOMS).forEach((reportKey) => {
605+
if (ReportUtils.shouldDisableWriteActions(REPORTS_WITH_WORKSPACE_ROOMS[reportKey]) || ReportUtils.isExpensifyOnlyParticipantInReport(REPORTS_WITH_WORKSPACE_ROOMS[reportKey])) {
606+
return;
607+
}
608+
filteredReportsWithWorkspaceRooms[reportKey] = REPORTS_WITH_WORKSPACE_ROOMS[reportKey];
609+
});
610+
588611
// When we also have a policy to return rooms in the results
589-
results = OptionsListUtils.getShareDestinationOptions(REPORTS_WITH_WORKSPACE_ROOMS, PERSONAL_DETAILS, [], '');
612+
results = OptionsListUtils.getShareDestinationOptions(filteredReportsWithWorkspaceRooms, PERSONAL_DETAILS, [], '');
590613

591614
// Then we should expect the DMS, the group chats and the workspace room to show
592615
// We should expect all the recent reports to show, excluding the archived rooms
593616
expect(results.recentReports.length).toBe(_.size(REPORTS_WITH_WORKSPACE_ROOMS) - 1);
594617

595618
// When we search for a workspace room
596-
results = OptionsListUtils.getShareDestinationOptions(REPORTS_WITH_WORKSPACE_ROOMS, PERSONAL_DETAILS, [], 'Avengers Room');
619+
results = OptionsListUtils.getShareDestinationOptions(filteredReportsWithWorkspaceRooms, PERSONAL_DETAILS, [], 'Avengers Room');
597620

598621
// Then we should expect only the workspace room to show
599622
expect(results.recentReports.length).toBe(1);
600623

601624
// When we search for a workspace room that doesn't exist
602-
results = OptionsListUtils.getShareDestinationOptions(REPORTS_WITH_WORKSPACE_ROOMS, PERSONAL_DETAILS, [], 'Mutants Lair');
625+
results = OptionsListUtils.getShareDestinationOptions(filteredReportsWithWorkspaceRooms, PERSONAL_DETAILS, [], 'Mutants Lair');
603626

604627
// Then we should expect no results to show
605628
expect(results.recentReports.length).toBe(0);

tests/unit/SidebarFilterTest.js

Lines changed: 8 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import wrapOnyxWithWaitForPromisesToResolve from '../utils/wrapOnyxWithWaitForPr
77
import CONST from '../../src/CONST';
88
import DateUtils from '../../src/libs/DateUtils';
99
import * as Localize from '../../src/libs/Localize';
10-
import * as Report from '../../src/libs/actions/Report';
1110

1211
// Be sure to include the mocked permissions library or else the beta tests won't work
1312
jest.mock('../../src/libs/Permissions');
@@ -127,54 +126,6 @@ describe('Sidebar', () => {
127126
);
128127
});
129128

130-
it('includes or excludes policy expensechats depending on the beta', () => {
131-
LHNTestUtils.getDefaultRenderedSidebarLinks();
132-
133-
// Given a policy expense report
134-
// and the user not being in any betas
135-
const report = {
136-
...LHNTestUtils.getFakeReport(),
137-
chatType: CONST.REPORT.CHAT_TYPE.POLICY_EXPENSE_CHAT,
138-
};
139-
140-
return (
141-
waitForPromisesToResolve()
142-
// When Onyx is updated to contain that data and the sidebar re-renders
143-
.then(() =>
144-
Onyx.multiSet({
145-
[ONYXKEYS.BETAS]: [],
146-
[ONYXKEYS.PERSONAL_DETAILS_LIST]: LHNTestUtils.fakePersonalDetails,
147-
[ONYXKEYS.IS_LOADING_REPORT_DATA]: false,
148-
[`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`]: report,
149-
}),
150-
)
151-
152-
// When the report has at least one ADDCOMMENT action to be rendered in the LNH
153-
.then(() => Report.addComment(report.reportID, 'Hi, this is a comment'))
154-
155-
// Then no reports are rendered in the LHN
156-
.then(() => {
157-
const hintText = Localize.translateLocal('accessibilityHints.navigatesToChat');
158-
const optionRows = screen.queryAllByAccessibilityHint(hintText);
159-
expect(optionRows).toHaveLength(0);
160-
})
161-
162-
// When the user is added to the policy expense beta and the sidebar re-renders
163-
.then(() =>
164-
Onyx.multiSet({
165-
[ONYXKEYS.BETAS]: [CONST.BETAS.POLICY_EXPENSE_CHAT],
166-
}),
167-
)
168-
169-
// Then there is one report rendered in the LHN
170-
.then(() => {
171-
const hintText = Localize.translateLocal('accessibilityHints.navigatesToChat');
172-
const optionRows = screen.queryAllByAccessibilityHint(hintText);
173-
expect(optionRows).toHaveLength(1);
174-
})
175-
);
176-
});
177-
178129
it('includes or excludes user created policy rooms depending on the beta', () => {
179130
LHNTestUtils.getDefaultRenderedSidebarLinks();
180131

@@ -335,7 +286,7 @@ describe('Sidebar', () => {
335286
};
336287

337288
// Given the user is in all betas
338-
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS, CONST.BETAS.POLICY_EXPENSE_CHAT];
289+
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS];
339290

340291
// Given there are 6 boolean variables tested in the filtering logic:
341292
// 1. isArchived
@@ -539,7 +490,7 @@ describe('Sidebar', () => {
539490
};
540491
LHNTestUtils.getDefaultRenderedSidebarLinks();
541492

542-
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS, CONST.BETAS.POLICY_EXPENSE_CHAT];
493+
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS];
543494

544495
return (
545496
waitForPromisesToResolve()
@@ -602,7 +553,7 @@ describe('Sidebar', () => {
602553
};
603554
LHNTestUtils.getDefaultRenderedSidebarLinks();
604555

605-
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS, CONST.BETAS.POLICY_EXPENSE_CHAT];
556+
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS];
606557

607558
return (
608559
waitForPromisesToResolve()
@@ -660,7 +611,7 @@ describe('Sidebar', () => {
660611
};
661612

662613
// Given the user is in all betas
663-
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS, CONST.BETAS.POLICY_EXPENSE_CHAT];
614+
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS];
664615

665616
// Given there are 6 boolean variables tested in the filtering logic:
666617
// 1. isArchived
@@ -753,7 +704,7 @@ describe('Sidebar', () => {
753704
};
754705

755706
// Given the user is in all betas
756-
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS, CONST.BETAS.POLICY_EXPENSE_CHAT];
707+
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS];
757708

758709
return (
759710
waitForPromisesToResolve()
@@ -804,7 +755,7 @@ describe('Sidebar', () => {
804755
};
805756

806757
// Given the user is in all betas
807-
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS, CONST.BETAS.POLICY_EXPENSE_CHAT];
758+
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS];
808759

809760
return (
810761
waitForPromisesToResolve()
@@ -853,7 +804,7 @@ describe('Sidebar', () => {
853804
};
854805

855806
// Given the user is in all betas
856-
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS, CONST.BETAS.POLICY_EXPENSE_CHAT];
807+
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS];
857808

858809
return (
859810
waitForPromisesToResolve()
@@ -898,7 +849,7 @@ describe('Sidebar', () => {
898849
};
899850

900851
// Given the user is in all betas
901-
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS, CONST.BETAS.POLICY_EXPENSE_CHAT];
852+
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS];
902853

903854
return (
904855
waitForPromisesToResolve()

tests/unit/SidebarOrderTest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ describe('Sidebar', () => {
574574
Report.addComment(report3.reportID, 'Hi, this is a comment');
575575

576576
// Given the user is in all betas
577-
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS, CONST.BETAS.POLICY_EXPENSE_CHAT];
577+
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS];
578578
LHNTestUtils.getDefaultRenderedSidebarLinks('0');
579579
return (
580580
waitForPromisesToResolve()
@@ -666,7 +666,7 @@ describe('Sidebar', () => {
666666
const report3 = LHNTestUtils.getFakeReport([5, 6], 1, true);
667667

668668
// Given the user is in all betas
669-
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS, CONST.BETAS.POLICY_EXPENSE_CHAT];
669+
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS];
670670
LHNTestUtils.getDefaultRenderedSidebarLinks('0');
671671
return (
672672
waitForPromisesToResolve()

tests/unit/SidebarTest.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('Sidebar', () => {
5656
};
5757

5858
// Given the user is in all betas
59-
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS, CONST.BETAS.POLICY_EXPENSE_CHAT];
59+
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS];
6060
LHNTestUtils.getDefaultRenderedSidebarLinks('0');
6161
return (
6262
waitForPromisesToResolve()
@@ -99,7 +99,7 @@ describe('Sidebar', () => {
9999
};
100100

101101
// Given the user is in all betas
102-
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS, CONST.BETAS.POLICY_EXPENSE_CHAT];
102+
const betas = [CONST.BETAS.DEFAULT_ROOMS, CONST.BETAS.POLICY_ROOMS];
103103
LHNTestUtils.getDefaultRenderedSidebarLinks('0');
104104
return (
105105
waitForPromisesToResolve()

0 commit comments

Comments
 (0)