From 57b855d4ac66f27f6905eaf942c0c0ac9301096c Mon Sep 17 00:00:00 2001
From: OSBotify <76178356+OSBotify@users.noreply.github.com>
Date: Tue, 16 May 2023 05:58:40 -0400
Subject: [PATCH 1/2] Merge pull request #18998 from
 Expensify/version-BUILD-C0C360C1-DF63-42C3-A9B0-4862AD99A2FE

Update version to 1.3.14-7 on main

(cherry picked from commit a2c613b1e13bc9f76da46141de0499d59875b255)
---
 android/app/build.gradle         | 4 ++--
 ios/NewExpensify/Info.plist      | 2 +-
 ios/NewExpensifyTests/Info.plist | 2 +-
 package-lock.json                | 4 ++--
 package.json                     | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/android/app/build.gradle b/android/app/build.gradle
index 712213d87aaa..1b145c90653d 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -106,8 +106,8 @@ android {
         minSdkVersion rootProject.ext.minSdkVersion
         targetSdkVersion rootProject.ext.targetSdkVersion
         multiDexEnabled rootProject.ext.multiDexEnabled
-        versionCode 1001031406
-        versionName "1.3.14-6"
+        versionCode 1001031407
+        versionName "1.3.14-7"
     }
 
     splits {
diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist
index d10d85866d13..70f154f8bec3 100644
--- a/ios/NewExpensify/Info.plist
+++ b/ios/NewExpensify/Info.plist
@@ -30,7 +30,7 @@
 		</dict>
 	</array>
 	<key>CFBundleVersion</key>
-	<string>1.3.14.6</string>
+	<string>1.3.14.7</string>
 	<key>ITSAppUsesNonExemptEncryption</key>
 	<false/>
 	<key>LSApplicationQueriesSchemes</key>
diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist
index 1f6d22b2790b..6e5de935fad8 100644
--- a/ios/NewExpensifyTests/Info.plist
+++ b/ios/NewExpensifyTests/Info.plist
@@ -19,6 +19,6 @@
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<key>CFBundleVersion</key>
-	<string>1.3.14.6</string>
+	<string>1.3.14.7</string>
 </dict>
 </plist>
diff --git a/package-lock.json b/package-lock.json
index 92d909efedf4..e79b8a9c47c9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
 {
   "name": "new.expensify",
-  "version": "1.3.14-6",
+  "version": "1.3.14-7",
   "lockfileVersion": 2,
   "requires": true,
   "packages": {
     "": {
       "name": "new.expensify",
-      "version": "1.3.14-6",
+      "version": "1.3.14-7",
       "hasInstallScript": true,
       "license": "MIT",
       "dependencies": {
diff --git a/package.json b/package.json
index c8f8c7c0802b..0f2d1a3adba3 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "new.expensify",
-  "version": "1.3.14-6",
+  "version": "1.3.14-7",
   "author": "Expensify, Inc.",
   "homepage": "https://new.expensify.com",
   "description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.",

From 91d77247e24f116ce203074dedd598729fd1e59c Mon Sep 17 00:00:00 2001
From: Maria D'Costa <maria@expensify.com>
Date: Tue, 16 May 2023 13:50:00 +0400
Subject: [PATCH 2/2] Merge pull request #17348 from
 Expensify/cmartins-allowDeletion

Allow money request deletion

(cherry picked from commit 3119b61e22862f7004cabfc62613c9b17135ad2d)
---
 src/languages/en.js                           |  5 +++--
 src/languages/es.js                           |  5 +++--
 src/libs/IOUUtils.js                          |  3 ++-
 src/libs/ReportActionsUtils.js                |  9 +++++++++
 src/libs/ReportUtils.js                       |  8 +++++---
 .../BaseReportActionContextMenu.js            |  2 +-
 .../report/ContextMenu/ContextMenuActions.js  |  2 +-
 .../PopoverReportActionContextMenu.js         | 14 ++++++++++----
 src/pages/home/report/ReportActionItem.js     | 19 ++++++++++++++++++-
 9 files changed, 52 insertions(+), 15 deletions(-)

diff --git a/src/languages/en.js b/src/languages/en.js
index f9d9eaf23826..c5060da2d03b 100755
--- a/src/languages/en.js
+++ b/src/languages/en.js
@@ -1,5 +1,6 @@
 import {CONST as COMMON_CONST} from 'expensify-common/lib/CONST';
 import CONST from '../CONST';
+import * as ReportActionsUtils from '../libs/ReportActionsUtils';
 
 /* eslint-disable max-len */
 export default {
@@ -253,8 +254,8 @@ export default {
         copyEmailToClipboard: 'Copy email to clipboard',
         markAsUnread: 'Mark as unread',
         editComment: 'Edit comment',
-        deleteComment: 'Delete comment',
-        deleteConfirmation: 'Are you sure you want to delete this comment?',
+        deleteAction: ({action}) => `Delete ${ReportActionsUtils.isMoneyRequestAction(action) ? 'request' : 'comment'}`,
+        deleteConfirmation: ({action}) => `Are you sure you want to delete this ${ReportActionsUtils.isMoneyRequestAction(action) ? 'request' : 'comment'}?`,
         onlyVisible: 'Only visible to',
         replyInThread: 'Reply in thread',
     },
diff --git a/src/languages/es.js b/src/languages/es.js
index 23114b5bc428..53c8043e4fa0 100644
--- a/src/languages/es.js
+++ b/src/languages/es.js
@@ -1,4 +1,5 @@
 import CONST from '../CONST';
+import * as ReportActionsUtils from '../libs/ReportActionsUtils';
 
 /* eslint-disable max-len */
 export default {
@@ -252,8 +253,8 @@ export default {
         copyEmailToClipboard: 'Copiar email al portapapeles',
         markAsUnread: 'Marcar como no leído',
         editComment: 'Editar comentario',
-        deleteComment: 'Eliminar comentario',
-        deleteConfirmation: '¿Estás seguro de que quieres eliminar este comentario?',
+        deleteAction: ({action}) => `Eliminar ${ReportActionsUtils.isMoneyRequestAction(action) ? 'pedido' : 'comentario'}`,
+        deleteConfirmation: ({action}) => `¿Estás seguro de que quieres eliminar este ${ReportActionsUtils.isMoneyRequestAction(action) ? 'pedido' : 'comentario'}`,
         onlyVisible: 'Visible sólo para',
         replyInThread: 'Responder en el hilo',
     },
diff --git a/src/libs/IOUUtils.js b/src/libs/IOUUtils.js
index f5ebefbad50c..7224e63f31e0 100644
--- a/src/libs/IOUUtils.js
+++ b/src/libs/IOUUtils.js
@@ -1,5 +1,6 @@
 import _ from 'underscore';
 import CONST from '../CONST';
+import * as ReportActionsUtils from './ReportActionsUtils';
 
 /**
  * Calculates the amount per user given a list of participants
@@ -74,7 +75,7 @@ function updateIOUOwnerAndTotal(iouReport, actorEmail, amount, currency, type =
  */
 function getIOUReportActions(reportActions, iouReport, type = '', pendingAction = '', filterRequestsInDifferentCurrency = false) {
     return _.chain(reportActions)
-        .filter((action) => action.originalMessage && action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && (!_.isEmpty(type) ? action.originalMessage.type === type : true))
+        .filter((action) => action.originalMessage && ReportActionsUtils.isMoneyRequestAction(action) && (!_.isEmpty(type) ? action.originalMessage.type === type : true))
         .filter((action) => action.originalMessage.IOUReportID.toString() === iouReport.reportID.toString())
         .filter((action) => (!_.isEmpty(pendingAction) ? action.pendingAction === pendingAction : true))
         .filter((action) => (filterRequestsInDifferentCurrency ? action.originalMessage.currency !== iouReport.currency : true))
diff --git a/src/libs/ReportActionsUtils.js b/src/libs/ReportActionsUtils.js
index 558afca9904e..098282639975 100644
--- a/src/libs/ReportActionsUtils.js
+++ b/src/libs/ReportActionsUtils.js
@@ -40,6 +40,14 @@ function isDeletedAction(reportAction) {
     return message.length === 0 || lodashGet(message, [0, 'html']) === '';
 }
 
+/**
+ * @param {Object} reportAction
+ * @returns {Boolean}
+ */
+function isMoneyRequestAction(reportAction) {
+    return lodashGet(reportAction, 'actionName', '') === CONST.REPORT.ACTIONS.TYPE.IOU;
+}
+
 /**
  * Returns the parentReportAction if the given report is a thread.
  *
@@ -332,6 +340,7 @@ export {
     getSortedReportActionsForDisplay,
     getLastClosedReportAction,
     getLatestReportActionFromOnyxData,
+    isMoneyRequestAction,
     getLinkedTransactionID,
     isCreatedTaskReportAction,
     getParentReportAction,
diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js
index 8fa24c8fb75c..11979433607a 100644
--- a/src/libs/ReportUtils.js
+++ b/src/libs/ReportUtils.js
@@ -184,6 +184,8 @@ function canEditReportAction(reportAction) {
 }
 
 /**
+ * Whether the Money Request report is settled
+ *
  * @param {String} reportID
  * @returns {Boolean}
  */
@@ -192,7 +194,7 @@ function isSettled(reportID) {
 }
 
 /**
- * Can only delete if it's an ADDCOMMENT, the author is this user.
+ * Can only delete if the author is this user and the action is an ADDCOMMENT action or an IOU action in an unsettled report
  *
  * @param {Object} reportAction
  * @returns {Boolean}
@@ -200,8 +202,8 @@ function isSettled(reportID) {
 function canDeleteReportAction(reportAction) {
     return (
         reportAction.actorEmail === sessionEmail &&
-        reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT &&
-        !ReportActionsUtils.isCreatedTaskReportAction(reportAction) &&
+        ((reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT && !ReportActionsUtils.isCreatedTaskReportAction(reportAction)) ||
+            (ReportActionsUtils.isMoneyRequestAction(reportAction) && !isSettled(reportAction.originalMessage.IOUReportID))) &&
         reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE
     );
 }
diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js
index 8467cc574370..d307d06b7984 100755
--- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js
+++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js
@@ -90,7 +90,7 @@ class BaseReportActionContextMenu extends React.Component {
                         return (
                             <ContextMenuItem
                                 icon={contextAction.icon}
-                                text={this.props.translate(contextAction.textTranslateKey)}
+                                text={this.props.translate(contextAction.textTranslateKey, {action: this.props.reportAction})}
                                 successIcon={contextAction.successIcon}
                                 successText={contextAction.successTextTranslateKey ? this.props.translate(contextAction.successTextTranslateKey) : undefined}
                                 isMini={this.props.isMini}
diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js
index 2b56094afc2b..0a9826441251 100644
--- a/src/pages/home/report/ContextMenu/ContextMenuActions.js
+++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js
@@ -243,7 +243,7 @@ export default [
         getDescription: () => {},
     },
     {
-        textTranslateKey: 'reportActionContextMenu.deleteComment',
+        textTranslateKey: 'reportActionContextMenu.deleteAction',
         icon: Expensicons.Trashcan,
         shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport) =>
             // Until deleting parent threads is supported in FE, we will prevent the user from deleting a thread parent
diff --git a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js
index 708e534d71c8..dfdf559e79c7 100644
--- a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js
+++ b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js
@@ -8,6 +8,8 @@ import PopoverWithMeasuredContent from '../../../../components/PopoverWithMeasur
 import BaseReportActionContextMenu from './BaseReportActionContextMenu';
 import ConfirmModal from '../../../../components/ConfirmModal';
 import CONST from '../../../../CONST';
+import * as ReportActionsUtils from '../../../../libs/ReportActionsUtils';
+import * as IOU from '../../../../libs/actions/IOU';
 
 const propTypes = {
     ...withLocalizePropTypes,
@@ -249,7 +251,12 @@ class PopoverReportActionContextMenu extends React.Component {
 
     confirmDeleteAndHideModal() {
         this.callbackWhenDeleteModalHide = () => (this.onComfirmDeleteModal = this.runAndResetCallback(this.onComfirmDeleteModal));
-        Report.deleteReportComment(this.state.reportID, this.state.reportAction);
+
+        if (ReportActionsUtils.isMoneyRequestAction(this.state.reportAction)) {
+            IOU.deleteMoneyRequest(this.state.reportID, this.state.reportAction.originalMessage.IOUReportID, this.state.reportAction, true);
+        } else {
+            Report.deleteReportComment(this.state.reportID, this.state.reportAction);
+        }
         this.setState({isDeleteCommentConfirmModalVisible: false});
     }
 
@@ -257,7 +264,6 @@ class PopoverReportActionContextMenu extends React.Component {
         this.callbackWhenDeleteModalHide = () => (this.onCancelDeleteModal = this.runAndResetCallback(this.onCancelDeleteModal));
         this.setState({
             reportID: '0',
-            reportAction: {},
             isDeleteCommentConfirmModalVisible: false,
             shouldSetModalVisibilityForDeleteConfirmation: true,
             isArchivedRoom: false,
@@ -313,13 +319,13 @@ class PopoverReportActionContextMenu extends React.Component {
                     />
                 </PopoverWithMeasuredContent>
                 <ConfirmModal
-                    title={this.props.translate('reportActionContextMenu.deleteComment')}
+                    title={this.props.translate('reportActionContextMenu.deleteAction', {action: this.state.reportAction})}
                     isVisible={this.state.isDeleteCommentConfirmModalVisible}
                     shouldSetModalVisibility={this.state.shouldSetModalVisibilityForDeleteConfirmation}
                     onConfirm={this.confirmDeleteAndHideModal}
                     onCancel={this.hideDeleteModal}
                     onModalHide={this.callbackWhenDeleteModalHide}
-                    prompt={this.props.translate('reportActionContextMenu.deleteConfirmation')}
+                    prompt={this.props.translate('reportActionContextMenu.deleteConfirmation', {action: this.state.reportAction})}
                     confirmText={this.props.translate('common.delete')}
                     cancelText={this.props.translate('common.cancel')}
                     danger
diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js
index c27d76ec149d..91e37ea32842 100644
--- a/src/pages/home/report/ReportActionItem.js
+++ b/src/pages/home/report/ReportActionItem.js
@@ -34,6 +34,7 @@ import * as User from '../../../libs/actions/User';
 import * as ReportUtils from '../../../libs/ReportUtils';
 import OfflineWithFeedback from '../../../components/OfflineWithFeedback';
 import * as ReportActions from '../../../libs/actions/ReportActions';
+import * as ReportActionsUtils from '../../../libs/ReportActionsUtils';
 import reportPropTypes from '../../reportPropTypes';
 import {ShowContextMenuContext} from '../../../components/ShowContextMenuContext';
 import focusTextInputAfterAnimation from '../../../libs/focusTextInputAfterAnimation';
@@ -48,7 +49,11 @@ import DisplayNames from '../../../components/DisplayNames';
 import personalDetailsPropType from '../../personalDetailsPropType';
 import ReportActionItemDraft from './ReportActionItemDraft';
 import TaskPreview from '../../../components/ReportActionItem/TaskPreview';
+<<<<<<< HEAD
 import * as ReportActionUtils from '../../../libs/ReportActionsUtils';
+=======
+import TaskAction from '../../../components/ReportActionItem/TaskAction';
+>>>>>>> 3119b61e22 (Merge pull request #17348 from Expensify/cmartins-allowDeletion)
 import Permissions from '../../../libs/Permissions';
 
 const propTypes = {
@@ -203,7 +208,19 @@ class ReportActionItem extends Component {
                     checkIfContextMenuActive={this.checkIfContextMenuActive}
                 />
             );
+<<<<<<< HEAD
         } else if (ReportActionUtils.isCreatedTaskReportAction(this.props.action)) {
+=======
+        } else if (this.props.action.actionName === CONST.REPORT.ACTIONS.TYPE.TASKCOMPLETED) {
+            children = (
+                <TaskAction
+                    taskReportID={this.props.action.originalMessage.taskReportID.toString()}
+                    actionName={this.props.action.actionName}
+                    isHovered={hovered}
+                />
+            );
+        } else if (ReportActionsUtils.isCreatedTaskReportAction(this.props.action)) {
+>>>>>>> 3119b61e22 (Merge pull request #17348 from Expensify/cmartins-allowDeletion)
             children = (
                 <TaskPreview
                     taskReportID={this.props.action.originalMessage.taskReportID.toString()}
@@ -358,7 +375,7 @@ class ReportActionItem extends Component {
                                     pendingAction={this.props.draftMessage ? null : this.props.action.pendingAction}
                                     errors={this.props.action.errors}
                                     errorRowStyles={[styles.ml10, styles.mr2]}
-                                    needsOffscreenAlphaCompositing={this.props.action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU}
+                                    needsOffscreenAlphaCompositing={ReportActionsUtils.isMoneyRequestAction(this.props.action)}
                                 >
                                     {isWhisper && (
                                         <View style={[styles.flexRow, styles.pl5, styles.pt2]}>
