Skip to content

Commit

Permalink
Merge pull request #24586 from WikusKriek/23438-Historical-IOUs-appea…
Browse files Browse the repository at this point in the history
…ring-in-LHN-like-a-pinned-chat

23438 historical IOUs appearing in LHN under pinned chats
  • Loading branch information
tgolen authored Aug 17, 2023
2 parents 332eeca + f440583 commit ca8372f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ function isWaitingForIOUActionFromCurrentUser(report) {
}

// Money request waiting for current user to add their credit bank account
if (report.ownerAccountID === currentUserAccountID && report.isWaitingOnBankAccount) {
if (report.hasOutstandingIOU && report.ownerAccountID === currentUserAccountID && report.isWaitingOnBankAccount) {
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/libs/SidebarUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function getOrderedReportIDs(currentReportId, allReportsDict, betas, policies, p
// 1. Pinned - Always sorted by reportDisplayName
// 2. Outstanding IOUs - Always sorted by iouReportAmount with the largest amounts at the top of the group
// 3. Drafts - Always sorted by reportDisplayName
// 4. Non-archived reports
// 4. Non-archived reports and settled IOUs
// - Sorted by lastVisibleActionCreated in default (most recent) view mode
// - Sorted by reportDisplayName in GSD (focus) view mode
// 5. Archived reports
Expand Down
13 changes: 11 additions & 2 deletions tests/unit/ReportUtilsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,16 +309,25 @@ describe('ReportUtils', () => {
expect(ReportUtils.isWaitingForIOUActionFromCurrentUser(report)).toBe(false);
});
});
it('returns true when the report has no oustanding IOU but is waiting for a bank account and the logged user is the report owner', () => {
it('returns false when the report has no oustanding IOU but is waiting for a bank account and the logged user is the report owner', () => {
const report = {
...LHNTestUtils.getFakeReport(),
hasOutstandingIOU: false,
ownerAccountID: currentUserAccountID,
isWaitingOnBankAccount: true,
};
expect(ReportUtils.isWaitingForIOUActionFromCurrentUser(report)).toBe(false);
});
it('returns true when the report has oustanding IOU and is waiting for a bank account and the logged user is the report owner', () => {
const report = {
...LHNTestUtils.getFakeReport(),
hasOutstandingIOU: true,
ownerAccountID: currentUserAccountID,
isWaitingOnBankAccount: true,
};
expect(ReportUtils.isWaitingForIOUActionFromCurrentUser(report)).toBe(true);
});
it('returns true when the report has no oustanding IOU but is waiting for a bank account and the logged user is not the report owner', () => {
it('returns false when the report has no oustanding IOU but is waiting for a bank account and the logged user is not the report owner', () => {
const report = {
...LHNTestUtils.getFakeReport(),
hasOutstandingIOU: false,
Expand Down

0 comments on commit ca8372f

Please sign in to comment.