Skip to content

Commit

Permalink
Fix isDM function to only be true for type chat
Browse files Browse the repository at this point in the history
  • Loading branch information
puneetlath committed Nov 7, 2023
1 parent fce7b70 commit e883529
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/libs/ReportUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ function isChatThread(report) {
* @returns {Boolean}
*/
function isDM(report) {
return !getChatType(report);
return isChatReport(report) && !getChatType(report);
}

/**
Expand Down Expand Up @@ -3617,7 +3617,7 @@ function hasIOUWaitingOnCurrentUserBankAccount(chatReport) {
* - in an open or submitted expense report tied to a policy expense chat the user owns
* - employee can request money in submitted expense report only if the policy has Instant Submit settings turned on
* - in an IOU report, which is not settled yet
* - in DM chat
* - in a 1:1 DM chat
*
* @param {Object} report
* @param {Array<Number>} otherParticipants
Expand All @@ -3629,6 +3629,11 @@ function canRequestMoney(report, otherParticipants) {
return false;
}

// Users can only request money in DMs if they are a 1:1 DM
if (isDM(report)) {
return otherParticipants.length === 1;
}

// Prevent requesting money if pending IOU report waiting for their bank account already exists
if (hasIOUWaitingOnCurrentUserBankAccount(report)) {
return false;
Expand Down

0 comments on commit e883529

Please sign in to comment.