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
2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,6 @@ function getSidebarOptions(
betas,
) {
let sideBarOptions = {
prioritizePinnedReports: true,
prioritizeIOUDebts: true,
prioritizeReportsWithDraftComments: true,
};
Expand All @@ -698,6 +697,7 @@ function getSidebarOptions(
maxRecentReportsToShow: 0, // Unlimited
sortByLastMessageTimestamp: true,
showChatPreviewLine: true,
prioritizePinnedReports: true,
...sideBarOptions,
});
}
Expand Down
57 changes: 47 additions & 10 deletions tests/unit/OptionsListUtilsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,28 @@ describe('OptionsListUtils', () => {
},
};

const REPORTS_WITH_MORE_PINS = {
...REPORTS,
13: {
lastVisitedTimestamp: 1610666739302,
lastMessageTimestamp: 1,
isPinned: true,
reportID: 13,
participants: ['d_email@email.com'],
reportName: 'D report name',
unreadActionCount: 0,
},
14: {
lastVisitedTimestamp: 1610666732302,
lastMessageTimestamp: 1,
isPinned: true,
reportID: 14,
participants: ['z_email@email.com'],
reportName: 'Z Report Name',
unreadActionCount: 0,
},
};

const PERSONAL_DETAILS_WITH_CONCIERGE = {
...PERSONAL_DETAILS,

Expand Down Expand Up @@ -494,7 +516,6 @@ describe('OptionsListUtils', () => {
]),
);


// Test by excluding Chronos from the results
results = OptionsListUtils.getNewChatOptions(
REPORTS_WITH_CHRONOS,
Expand Down Expand Up @@ -597,23 +618,39 @@ describe('OptionsListUtils', () => {
() => Report.setReportWithDraft(1, true)
.then(() => {
// When we call getSidebarOptions() with no search value
const results = OptionsListUtils.getSidebarOptions(REPORTS, PERSONAL_DETAILS, 0, CONST.PRIORITY_MODE.GSD);
const results = OptionsListUtils.getSidebarOptions(REPORTS_WITH_MORE_PINS, PERSONAL_DETAILS, 0, CONST.PRIORITY_MODE.GSD);

// Then expect all of the reports to be shown both multiple and single participant except the
// report that has no lastMessageTimestamp and the chat with Thor who's message is read
expect(results.recentReports.length).toBe(_.size(REPORTS) - 2);
expect(results.recentReports.length).toBe(_.size(REPORTS_WITH_MORE_PINS) - 2);

// That no personalDetails are shown
expect(results.personalDetails.length).toBe(0);

// And Mister Fantastic is alphabetically the fourth report and has an unread message
// despite being pinned
expect(results.recentReports[4].login).toBe('reedrichards@expensify.com');
// Pinned reports are always on the top in alphabetical order regardless of whether they are unread or have IOU debt.
// D report name (Alphabetically first among pinned reports)
expect(results.recentReports[0].login).toBe('d_email@email.com');

// Mister Fantastic report name (Alphabetically second among pinned reports)
expect(results.recentReports[1].login).toBe('reedrichards@expensify.com');

// Z report name (Alphabetically third among pinned reports)
expect(results.recentReports[2].login).toBe('z_email@email.com');

// Unpinned report name ordered alphabetically after pinned reports
// Black Panther report name has unread message
expect(results.recentReports[3].login).toBe('tchalla@expensify.com');

// Captain America report name has unread message
expect(results.recentReports[4].login).toBe('steverogers@expensify.com');

// Invisible woman report name has unread message
expect(results.recentReports[5].login).toBe('suestorm@expensify.com');

// And Black Panther is alphabetically the first report and has an unread message
expect(results.recentReports[0].login).toBe('tchalla@expensify.com');
Comment thread
K4tsuki marked this conversation as resolved.
Outdated
// Mister Sinister report name has IOU debt
expect(results.recentReports[7].login).toBe('mistersinister@marauders.com');

// And Mister Sinister is alphabetically the fifth report and has an IOU debt despite not being pinned
expect(results.recentReports[5].login).toBe('mistersinister@marauders.com');
// Spider-Man report name is last report and has unread message
expect(results.recentReports[8].login).toBe('peterparker@expensify.com');
}));
});