From f14d990685b1f176f356d13084a0e9460ac71bf2 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 28 Nov 2022 13:34:32 -1000 Subject: [PATCH 1/6] Block send/request when the chat is a default or user created policy room --- src/pages/home/report/ReportActionCompose.js | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index 37e5602ca692a..954909a3a619a 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -280,18 +280,22 @@ class ReportActionCompose extends React.Component { }]; } - iouOptions.push({ - icon: Expensicons.MoneyCircle, - text: this.props.translate('iou.requestMoney'), - onSelected: () => Navigation.navigate(ROUTES.getIouRequestRoute(this.props.reportID)), - }); - if (Permissions.canUseIOUSend(this.props.betas)) { + // We do not allow requesting or sending money for a chat room (i.e. default or policy created room) as those are only enabled for DMs and policy expense chats + if (!ReportUtils.isChatRoom(this.props.report)) { iouOptions.push({ - icon: Expensicons.Send, - text: this.props.translate('iou.sendMoney'), - onSelected: () => Navigation.navigate(ROUTES.getIOUSendRoute(this.props.reportID)), + icon: Expensicons.MoneyCircle, + text: this.props.translate('iou.requestMoney'), + onSelected: () => Navigation.navigate(ROUTES.getIouRequestRoute(this.props.reportID)), }); + if (Permissions.canUseIOUSend(this.props.betas)) { + iouOptions.push({ + icon: Expensicons.Send, + text: this.props.translate('iou.sendMoney'), + onSelected: () => Navigation.navigate(ROUTES.getIOUSendRoute(this.props.reportID)), + }); + } } + return iouOptions; } From d32e68866ef2f073a90c950ba7d16ce93debed7b Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 28 Nov 2022 13:45:44 -1000 Subject: [PATCH 2/6] Fix up comments. Make sure the bill split option shows whenever/wherever there are multiple participants --- src/pages/home/report/ReportActionCompose.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index 954909a3a619a..b7e3ab55b9b90 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -272,15 +272,16 @@ class ReportActionCompose extends React.Component { return []; } + // We always allow bill splitting for any chat type as long as there are multiple participants if (hasMultipleParticipants) { - return [{ + iouOptions.push({ icon: Expensicons.Receipt, text: this.props.translate('iou.splitBill'), onSelected: () => Navigation.navigate(ROUTES.getIouSplitRoute(this.props.reportID)), - }]; + }); } - // We do not allow requesting or sending money for a chat room (i.e. default or policy created room) as those are only enabled for DMs and policy expense chats + // We only allow requesting or sending money in non "chat rooms" (i.e. default or policy created room). These features only work for DMs and policy expense chats. if (!ReportUtils.isChatRoom(this.props.report)) { iouOptions.push({ icon: Expensicons.MoneyCircle, From 68a4eb9eb74798d4702b8de8a8779e751d042293 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 28 Nov 2022 14:03:30 -1000 Subject: [PATCH 3/6] Change to else if as we only want split bill OR request/send money --- src/pages/home/report/ReportActionCompose.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index b7e3ab55b9b90..49bdc71708e21 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -279,10 +279,8 @@ class ReportActionCompose extends React.Component { text: this.props.translate('iou.splitBill'), onSelected: () => Navigation.navigate(ROUTES.getIouSplitRoute(this.props.reportID)), }); - } - - // We only allow requesting or sending money in non "chat rooms" (i.e. default or policy created room). These features only work for DMs and policy expense chats. - if (!ReportUtils.isChatRoom(this.props.report)) { + } else if (!ReportUtils.isChatRoom(this.props.report)) { + // We only allow requesting or sending money in non "chat rooms" (i.e. default or policy created room). These features only work for DMs and policy expense chats. iouOptions.push({ icon: Expensicons.MoneyCircle, text: this.props.translate('iou.requestMoney'), From 253fda091f3dce436328465bd3eeaeb4177d9c19 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 28 Nov 2022 15:02:42 -1000 Subject: [PATCH 4/6] improve comment --- src/pages/home/report/ReportActionCompose.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index 49bdc71708e21..e8aa03c82a913 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -272,7 +272,7 @@ class ReportActionCompose extends React.Component { return []; } - // We always allow bill splitting for any chat type as long as there are multiple participants + // We always allow bill splitting for any chat type as long as there are multiple participants. if (hasMultipleParticipants) { iouOptions.push({ icon: Expensicons.Receipt, @@ -280,7 +280,9 @@ class ReportActionCompose extends React.Component { onSelected: () => Navigation.navigate(ROUTES.getIouSplitRoute(this.props.reportID)), }); } else if (!ReportUtils.isChatRoom(this.props.report)) { - // We only allow requesting or sending money in non "chat rooms" (i.e. default or policy created room). These features only work for DMs and policy expense chats. + // If we don't have multiple participants then we only allow requesting or sending money in non "chat rooms" + // (i.e. default rooms like #announce or user created rooms). These features only work for DMs and policy expense chats, + // but we only show these options in lieu of a Split Bill option). iouOptions.push({ icon: Expensicons.MoneyCircle, text: this.props.translate('iou.requestMoney'), From 957fadd97e747f5eead675bf71bbd51a9bc27d88 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Thu, 1 Dec 2022 13:58:16 -1000 Subject: [PATCH 5/6] Clean up comment --- src/pages/home/report/ReportActionCompose.js | 43 ++++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index e8aa03c82a913..0ec9b879bcf20 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -266,38 +266,37 @@ class ReportActionCompose extends React.Component { const participants = _.filter(reportParticipants, email => this.props.currentUserPersonalDetails.login !== email); const hasExcludedIOUEmails = lodashIntersection(reportParticipants, CONST.EXPENSIFY_EMAILS).length > 0; const hasMultipleParticipants = participants.length > 1; - const iouOptions = []; if (hasExcludedIOUEmails || participants.length === 0 || !Permissions.canUseIOU(this.props.betas)) { return []; } - // We always allow bill splitting for any chat type as long as there are multiple participants. - if (hasMultipleParticipants) { - iouOptions.push({ - icon: Expensicons.Receipt, - text: this.props.translate('iou.splitBill'), - onSelected: () => Navigation.navigate(ROUTES.getIouSplitRoute(this.props.reportID)), - }); - } else if (!ReportUtils.isChatRoom(this.props.report)) { - // If we don't have multiple participants then we only allow requesting or sending money in non "chat rooms" - // (i.e. default rooms like #announce or user created rooms). These features only work for DMs and policy expense chats, - // but we only show these options in lieu of a Split Bill option). - iouOptions.push({ + // User created policy rooms and default rooms like #admins or #announce will always have the Split Bill option + // unless there are no participants at all (e.g. #admins room for a policy with only 1 admin) + // DM chats and workspace chats will have the Split Bill option only when there are at least 3 people in the chat. + if (ReportUtils.isChatRoom(this.props.report) || hasMultipleParticipants) { + return [ + { + icon: Expensicons.Receipt, + text: this.props.translate('iou.splitBill'), + onSelected: () => Navigation.navigate(ROUTES.getIouSplitRoute(this.props.reportID)), + }, + ]; + } + + // DM chats and workspace chats that only have 2 people will see the Send / Request money options. + return [ + { icon: Expensicons.MoneyCircle, text: this.props.translate('iou.requestMoney'), onSelected: () => Navigation.navigate(ROUTES.getIouRequestRoute(this.props.reportID)), - }); - if (Permissions.canUseIOUSend(this.props.betas)) { - iouOptions.push({ - icon: Expensicons.Send, + }, + ...(Permissions.canUseIOUSend(this.props.betas) ? + [{icon: Expensicons.Send, text: this.props.translate('iou.sendMoney'), onSelected: () => Navigation.navigate(ROUTES.getIOUSendRoute(this.props.reportID)), - }); - } - } - - return iouOptions; + }] : []), + ]; } /** From 60deae76637b876eb7ce974cd8cff52ceb0863a2 Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Thu, 1 Dec 2022 14:03:22 -1000 Subject: [PATCH 6/6] fix style --- src/pages/home/report/ReportActionCompose.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index 0ec9b879bcf20..a01924d05d9ab 100644 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -291,11 +291,14 @@ class ReportActionCompose extends React.Component { text: this.props.translate('iou.requestMoney'), onSelected: () => Navigation.navigate(ROUTES.getIouRequestRoute(this.props.reportID)), }, - ...(Permissions.canUseIOUSend(this.props.betas) ? - [{icon: Expensicons.Send, - text: this.props.translate('iou.sendMoney'), - onSelected: () => Navigation.navigate(ROUTES.getIOUSendRoute(this.props.reportID)), - }] : []), + ...(Permissions.canUseIOUSend(this.props.betas) + ? [ + { + icon: Expensicons.Send, + text: this.props.translate('iou.sendMoney'), + onSelected: () => Navigation.navigate(ROUTES.getIOUSendRoute(this.props.reportID)), + }] + : []), ]; }