Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show empty policyExpenseChats in LHN just like defaultRooms #8476

Merged
merged 25 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
956dc14
Show empty policyExpenseChats in LHN just like defaultRooms
Apr 4, 2022
4e40cd2
Merge branch 'main' of github.com:Expensify/App into amal-workspace-c…
Apr 5, 2022
42158c4
Fix boolean logic so active rooms are showing instead of inactive ones
Apr 5, 2022
9d7ca21
Remove extra variable use
Apr 7, 2022
b0727c2
more clear comment
Apr 7, 2022
bfcff67
Merge branch 'main' of github.com:Expensify/App into amal-workspace-c…
Apr 12, 2022
b6e8866
Merge branch 'main' of github.com:Expensify/App into amal-workspace-c…
Apr 14, 2022
b289cf6
Better comment
Apr 15, 2022
4158a3b
DRY variables
Apr 15, 2022
4fcb88d
Add empty policyExpenseChat for tests
Apr 15, 2022
d038730
Add default room for testing
Apr 15, 2022
3fefa46
Fix test for defaultRooms
Apr 15, 2022
8f702f3
Better comment
Apr 15, 2022
85a8d4c
Merge branch 'main' of github.com:Expensify/App into amal-workspace-c…
Apr 15, 2022
a532e98
use singlequotes for style
Apr 15, 2022
4f7b756
Fix typo
Apr 15, 2022
b41b27e
Better test comments
Apr 18, 2022
5bbe670
Remove policyExpenseChat and defaultRooms from general report filteri…
Apr 18, 2022
fb12ea4
Add separate tests for empty policyExpenseChats and defaultRooms in s…
Apr 18, 2022
03ce590
Add archived rooms to empty rooms tests
Apr 18, 2022
00af71e
Add test for GSD priority
Apr 18, 2022
c002367
Make this test only use relevant types of chats
Apr 18, 2022
be38bd0
Add more details to tests
Apr 18, 2022
c25da1a
Merge branch 'main' of github.com:Expensify/App into amal-workspace-c…
Apr 18, 2022
156d7af
Fix comment typo
Apr 18, 2022
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
10 changes: 8 additions & 2 deletions src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,13 @@ function getOptions(reports, personalDetails, activeReportID, {
: '';

const reportContainsIOUDebt = iouReportOwner && iouReportOwner !== currentUserLogin;
const shouldFilterReportIfEmpty = !showReportsWithNoComments && report.lastMessageTimestamp === 0 && !isDefaultRoom;
const shouldFilterReportIfEmpty = !showReportsWithNoComments && report.lastMessageTimestamp === 0

// We make exceptions for defaultRooms and policyExpenseChats so we can immediately
// highlight them in the LHN when they are created and have no messsages yet. We do
// not give archived rooms this exception since they do not need to be higlihted.
&& !(!ReportUtils.isArchivedRoom(report) && (isDefaultRoom || isPolicyExpenseChat));

const shouldFilterReportIfRead = hideReadReports && report.unreadActionCount === 0;
const shouldFilterReport = shouldFilterReportIfEmpty || shouldFilterReportIfRead;
if (report.reportID !== activeReportID
Expand All @@ -426,7 +432,7 @@ function getOptions(reports, personalDetails, activeReportID, {
// Save the report in the map if this is a single participant so we can associate the reportID with the
// personal detail option later. Individuals should not be associated with single participant
// policyExpenseChats or chatRooms since those are not people.
if (logins.length <= 1 && !ReportUtils.isPolicyExpenseChat(report) && !ReportUtils.isChatRoom(report)) {
if (logins.length <= 1 && !isPolicyExpenseChat && !isChatRoom) {
reportMapForLogins[logins[0]] = report;
}
const isSearchingSomeonesPolicyExpenseChat = !report.isOwnPolicyExpenseChat && searchValue !== '';
Expand Down
98 changes: 98 additions & 0 deletions tests/unit/OptionsListUtilsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -675,4 +675,102 @@ describe('OptionsListUtils', () => {
// Spider-Man report name is last report and has unread message
expect(results.recentReports[8].login).toBe('peterparker@expensify.com');
}));

it('getSidebarOptions() with empty policyExpenseChats and defaultRooms', () => {
const reportsWithEmptyChatRooms = {
// This report is a policyExpenseChat without any messages in it (i.e. no lastMessageTimestamp)
10: {
chatType: 'policyExpenseChat',
hasOutstandingIOU: false,
isOwnPolicyExpenseChat: true,
isPinned: false,
lastMessageTimestamp: 0,
lastVisitedTimestamp: 1610666739302,
participants: ['test3@instantworkspace.com'],
policyID: 'Whatever',
reportID: 10,
reportName: "Someone's workspace",
unreadActionCount: 0,
visibility: undefined,
},

// This is an archived version of the above policyExpenseChat
11: {
chatType: 'policyExpenseChat',
hasOutstandingIOU: false,
isOwnPolicyExpenseChat: true,
isPinned: false,
lastMessageTimestamp: 0,
lastVisitedTimestamp: 1610666739302,
participants: ['test3@instantworkspace.com'],
policyID: 'Whatever',
reportID: 11,
reportName: "Someone's workspace",
unreadActionCount: 0,
visibility: undefined,
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
statusNum: CONST.REPORT.STATUS.CLOSED,
},

// This report is a defaultRoom without any messages in it (i.e. no lastMessageTimestamp)
12: {
chatType: 'policyAdmins',
hasOutstandingIOU: false,
isPinned: false,
lastMessageTimestamp: 0,
lastVisitedTimestamp: 1610666739302,
participants: ['test3@instantworkspace.com'],
policyID: 'Whatever',
reportID: 12,
reportName: '#admins',
unreadActionCount: 0,
visibility: undefined,
},

// This is an archived version of the above defaultRoom
13: {
chatType: 'policyAdmins',
hasOutstandingIOU: false,
isPinned: false,
lastMessageTimestamp: 0,
lastVisitedTimestamp: 1610666739302,
participants: ['test3@instantworkspace.com'],
policyID: 'Whatever',
reportID: 13,
reportName: '#admins',
unreadActionCount: 0,
visibility: undefined,
stateNum: CONST.REPORT.STATE_NUM.SUBMITTED,
statusNum: CONST.REPORT.STATUS.CLOSED,
},
};

// First we call getSidebarOptions() with no search value and default priority mode
let results = OptionsListUtils.getSidebarOptions(
reportsWithEmptyChatRooms,
PERSONAL_DETAILS,
0,
CONST.PRIORITY_MODE.DEFAULT,
);

// Then expect all of the reports to be shown except the archived policyExpenseChats and defaultRooms
expect(results.recentReports.length).toBe(_.size(reportsWithEmptyChatRooms) - 2);

expect(results.recentReports[0].isPolicyExpenseChat).toBe(true);
expect(results.recentReports[0].text).toBe("Someone's workspace");

expect(results.recentReports[1].isChatRoom).toBe(true);
expect(results.recentReports[1].text).toBe('#admins');

// Now we call getSidebarOptions() with no search value and GSD priority mode
results = OptionsListUtils.getSidebarOptions(
reportsWithEmptyChatRooms,
PERSONAL_DETAILS,
0,
CONST.PRIORITY_MODE.GSD,
);

// None of the chats should be here since they've all been read
expect(results.recentReports.length).toBe(0);
});
});