From 99027f8ae0e81c3ef79ac7dd7945bf5631a32b97 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 12 Apr 2023 13:51:32 +0200 Subject: [PATCH 01/22] add delete to iou context menu --- src/libs/ReportUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 4e7305a6d2f7..300a8ca7fcaa 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -158,7 +158,7 @@ function canEditReportAction(reportAction) { */ function canDeleteReportAction(reportAction) { return reportAction.actorEmail === sessionEmail - && reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT + && _.contains([CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, CONST.REPORT.ACTIONS.TYPE.IOU], reportAction.actionName) && reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; } From 9edaa871b8c894fa1d52002ea70e926c54156f63 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 12 Apr 2023 14:07:41 +0200 Subject: [PATCH 02/22] update canDeleteReportAction --- src/libs/ReportUtils.js | 7 ++++--- src/pages/home/report/ContextMenu/ContextMenuActions.js | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index 300a8ca7fcaa..cd9792dacc72 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -151,14 +151,15 @@ function canEditReportAction(reportAction) { } /** - * 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 + * @param {Boolean} isReportSettled * @returns {Boolean} */ -function canDeleteReportAction(reportAction) { +function canDeleteReportAction(reportAction, isReportSettled) { return reportAction.actorEmail === sessionEmail - && _.contains([CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, CONST.REPORT.ACTIONS.TYPE.IOU], reportAction.actionName) + && (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT || (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && !isReportSettled)) && reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; } diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 385fee477f7b..f2a3e25eede6 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -237,8 +237,8 @@ export default [ { textTranslateKey: 'reportActionContextMenu.deleteComment', icon: Expensicons.Trashcan, - shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport) => type === CONTEXT_MENU_TYPES.REPORT_ACTION - && ReportUtils.canDeleteReportAction(reportAction) && !isArchivedRoom && !isChronosReport, + shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport, isReportSettled) => type === CONTEXT_MENU_TYPES.REPORT_ACTION + && ReportUtils.canDeleteReportAction(reportAction, isReportSettled) && !isArchivedRoom && !isChronosReport, onPress: (closePopover, {reportID, reportAction}) => { if (closePopover) { // Hide popover, then call showDeleteConfirmModal From e6948b0505dee06dde2dc38c949b6248dfdf6744 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 12 Apr 2023 14:10:17 +0200 Subject: [PATCH 03/22] add isReportSettled prop --- .../home/report/ContextMenu/BaseReportActionContextMenu.js | 5 +++++ src/pages/home/report/ReportActionItem.js | 1 + 2 files changed, 6 insertions(+) diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js index e562a417d423..6f802c229fd4 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js @@ -27,6 +27,9 @@ const propTypes = { /** Whether the provided report is an archived room */ isArchivedRoom: PropTypes.bool, + /** Whether the provided report has been reimbursed */ + isReportSettled: PropTypes.bool, + contentRef: PropTypes.oneOfType([PropTypes.node, PropTypes.object, PropTypes.func]), ...genericReportActionContextMenuPropTypes, @@ -40,6 +43,7 @@ const defaultProps = { contentRef: null, isChronosReport: false, isArchivedRoom: false, + isReportSettled: false, ...GenericReportActionContextMenuDefaultProps, }; class BaseReportActionContextMenu extends React.Component { @@ -60,6 +64,7 @@ class BaseReportActionContextMenu extends React.Component { this.props.betas, this.props.anchor, this.props.isChronosReport, + this.props.isReportSettled, ); return (this.props.isVisible || this.state.shouldKeepOpen) && ( diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 8cb3bd38e12d..48b5bca48d74 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -298,6 +298,7 @@ class ReportActionItem extends Component { } draftMessage={this.props.draftMessage} isChronosReport={ReportUtils.chatIncludesChronos(this.props.report)} + isReportSettled={this.props.report.status === CONST.REPORT.REPORT.STATUS.REIMBURSED} /> )} From b12bf1d7b0a0821639e2ace1092d83b543197792 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 12 Apr 2023 14:15:19 +0200 Subject: [PATCH 04/22] add isReportSettled param to context menu --- .../report/ContextMenu/PopoverReportActionContextMenu.js | 7 +++++++ .../home/report/ContextMenu/ReportActionContextMenu.js | 3 +++ 2 files changed, 10 insertions(+) diff --git a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js index 4883d2f37aa7..154a96013ecf 100644 --- a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js @@ -39,6 +39,7 @@ class PopoverReportActionContextMenu extends React.Component { }, isArchivedRoom: false, isChronosReport: false, + isReportSettled: false, }; this.onPopoverShow = () => {}; this.onPopoverHide = () => {}; @@ -125,6 +126,7 @@ class PopoverReportActionContextMenu extends React.Component { * @param {Function} [onHide] - Run a callback when Menu is hidden * @param {Boolean} isArchivedRoom - Whether the provided report is an archived room * @param {Boolean} isChronosReport - Flag to check if the chat participant is Chronos + * @param {Boolean} isReportSettled - Whether the provided report has been reimbursed */ showContextMenu( type, @@ -138,6 +140,7 @@ class PopoverReportActionContextMenu extends React.Component { onHide = () => {}, isArchivedRoom, isChronosReport, + isReportSettled, ) { const nativeEvent = event.nativeEvent || {}; this.contextMenuAnchor = contextMenuAnchor; @@ -168,6 +171,7 @@ class PopoverReportActionContextMenu extends React.Component { reportActionDraftMessage: draftMessage, isArchivedRoom, isChronosReport, + isReportSettled, }); }); } @@ -242,6 +246,7 @@ class PopoverReportActionContextMenu extends React.Component { reportAction={this.state.reportAction} isArchivedRoom={this.state.isArchivedRoom} isChronosReport={this.state.isChronosReport} + isReportSettled={this.state.isReportSettled} anchor={this.contextMenuTargetNode} contentRef={this.setContentRef} /> @@ -273,6 +278,7 @@ class PopoverReportActionContextMenu extends React.Component { shouldSetModalVisibilityForDeleteConfirmation: true, isArchivedRoom: false, isChronosReport: false, + isReportSettled: false, }); } @@ -319,6 +325,7 @@ class PopoverReportActionContextMenu extends React.Component { draftMessage={this.state.reportActionDraftMessage} isArchivedRoom={this.state.isArchivedRoom} isChronosReport={this.state.isChronosReport} + isReportSettled={this.state.isReportSettled} anchor={this.contextMenuTargetNode} contentRef={this.contentRef} /> diff --git a/src/pages/home/report/ContextMenu/ReportActionContextMenu.js b/src/pages/home/report/ContextMenu/ReportActionContextMenu.js index df544f2e7202..c83549cabb81 100644 --- a/src/pages/home/report/ContextMenu/ReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/ReportActionContextMenu.js @@ -16,6 +16,7 @@ const contextMenuRef = React.createRef(); * @param {Function} [onHide=() => {}] - Run a callback when Menu is hidden * @param {Boolean} isArchivedRoom - Whether the provided report is an archived room * @param {Boolean} isChronosReport - Flag to check if the chat participant is Chronos + * @param {Boolean} isReportSettled - Whether the provided report has been reimbursed */ function showContextMenu( type, @@ -29,6 +30,7 @@ function showContextMenu( onHide = () => {}, isArchivedRoom = false, isChronosReport = false, + isReportSettled = false, ) { if (!contextMenuRef.current) { return; @@ -45,6 +47,7 @@ function showContextMenu( onHide, isArchivedRoom, isChronosReport, + isReportSettled, ); } From 012f2e5fa6b84323b9dc2c52bbca7c824c0c1b01 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 12 Apr 2023 14:25:23 +0200 Subject: [PATCH 05/22] fix const typo --- src/pages/home/report/ReportActionItem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 48b5bca48d74..3453b735f33b 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -298,7 +298,7 @@ class ReportActionItem extends Component { } draftMessage={this.props.draftMessage} isChronosReport={ReportUtils.chatIncludesChronos(this.props.report)} - isReportSettled={this.props.report.status === CONST.REPORT.REPORT.STATUS.REIMBURSED} + isReportSettled={this.props.report.status === CONST.REPORT.STATUS.REIMBURSED} /> )} From dc0cb475417b30377251c3bc53372efe95880a61 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 12 Apr 2023 14:45:26 +0200 Subject: [PATCH 06/22] create isReportSettled --- src/libs/ReportUtils.js | 5 +++++ src/pages/home/report/ReportActionItem.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index cd9792dacc72..b33abfbe885b 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -1703,6 +1703,10 @@ function canLeaveRoom(report, isPolicyMember) { return true; } +function isReportSettled(report) { + return report.status === CONST.REPORT.STATUS.REIMBURSED; +} + export { getReportParticipantsTitle, isReportMessageAttachment, @@ -1771,4 +1775,5 @@ export { getSmallSizeAvatar, getMoneyRequestOptions, canRequestMoney, + isReportSettled, }; diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 3453b735f33b..2fd07de1d8d6 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -298,7 +298,7 @@ class ReportActionItem extends Component { } draftMessage={this.props.draftMessage} isChronosReport={ReportUtils.chatIncludesChronos(this.props.report)} - isReportSettled={this.props.report.status === CONST.REPORT.STATUS.REIMBURSED} + isReportSettled={this.props.iouReport.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED} /> )} From e86c484116b63bde273f1ddaec8c19f4ab2c8d01 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 12 Apr 2023 14:50:47 +0200 Subject: [PATCH 07/22] rm isReportSettled props and params --- src/libs/ReportUtils.js | 20 ++++++++++++------- .../BaseReportActionContextMenu.js | 5 ----- .../report/ContextMenu/ContextMenuActions.js | 4 ++-- .../PopoverReportActionContextMenu.js | 7 ------- .../ContextMenu/ReportActionContextMenu.js | 3 --- src/pages/home/report/ReportActionItem.js | 1 - 6 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index b33abfbe885b..e070cac6e76e 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -150,16 +150,26 @@ function canEditReportAction(reportAction) { && reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; } +/** + * Returns whether the Money Request report has been reimbursed + * + * @param {String} reportID + * @returns {Boolean} + */ +function isReportSettled(reportID) { + return allReports[reportID].status === CONST.REPORT.STATUS.REIMBURSED; +} + /** * 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 - * @param {Boolean} isReportSettled * @returns {Boolean} */ -function canDeleteReportAction(reportAction, isReportSettled) { +function canDeleteReportAction(reportAction) { return reportAction.actorEmail === sessionEmail - && (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT || (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && !isReportSettled)) + && (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT + || (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && !isReportSettled(reportAction.originalMessage.IOUReportID))) && reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; } @@ -1703,10 +1713,6 @@ function canLeaveRoom(report, isPolicyMember) { return true; } -function isReportSettled(report) { - return report.status === CONST.REPORT.STATUS.REIMBURSED; -} - export { getReportParticipantsTitle, isReportMessageAttachment, diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js index 6f802c229fd4..e562a417d423 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js @@ -27,9 +27,6 @@ const propTypes = { /** Whether the provided report is an archived room */ isArchivedRoom: PropTypes.bool, - /** Whether the provided report has been reimbursed */ - isReportSettled: PropTypes.bool, - contentRef: PropTypes.oneOfType([PropTypes.node, PropTypes.object, PropTypes.func]), ...genericReportActionContextMenuPropTypes, @@ -43,7 +40,6 @@ const defaultProps = { contentRef: null, isChronosReport: false, isArchivedRoom: false, - isReportSettled: false, ...GenericReportActionContextMenuDefaultProps, }; class BaseReportActionContextMenu extends React.Component { @@ -64,7 +60,6 @@ class BaseReportActionContextMenu extends React.Component { this.props.betas, this.props.anchor, this.props.isChronosReport, - this.props.isReportSettled, ); return (this.props.isVisible || this.state.shouldKeepOpen) && ( diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index f2a3e25eede6..385fee477f7b 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -237,8 +237,8 @@ export default [ { textTranslateKey: 'reportActionContextMenu.deleteComment', icon: Expensicons.Trashcan, - shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport, isReportSettled) => type === CONTEXT_MENU_TYPES.REPORT_ACTION - && ReportUtils.canDeleteReportAction(reportAction, isReportSettled) && !isArchivedRoom && !isChronosReport, + shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport) => type === CONTEXT_MENU_TYPES.REPORT_ACTION + && ReportUtils.canDeleteReportAction(reportAction) && !isArchivedRoom && !isChronosReport, onPress: (closePopover, {reportID, reportAction}) => { if (closePopover) { // Hide popover, then call showDeleteConfirmModal diff --git a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js index 154a96013ecf..4883d2f37aa7 100644 --- a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js @@ -39,7 +39,6 @@ class PopoverReportActionContextMenu extends React.Component { }, isArchivedRoom: false, isChronosReport: false, - isReportSettled: false, }; this.onPopoverShow = () => {}; this.onPopoverHide = () => {}; @@ -126,7 +125,6 @@ class PopoverReportActionContextMenu extends React.Component { * @param {Function} [onHide] - Run a callback when Menu is hidden * @param {Boolean} isArchivedRoom - Whether the provided report is an archived room * @param {Boolean} isChronosReport - Flag to check if the chat participant is Chronos - * @param {Boolean} isReportSettled - Whether the provided report has been reimbursed */ showContextMenu( type, @@ -140,7 +138,6 @@ class PopoverReportActionContextMenu extends React.Component { onHide = () => {}, isArchivedRoom, isChronosReport, - isReportSettled, ) { const nativeEvent = event.nativeEvent || {}; this.contextMenuAnchor = contextMenuAnchor; @@ -171,7 +168,6 @@ class PopoverReportActionContextMenu extends React.Component { reportActionDraftMessage: draftMessage, isArchivedRoom, isChronosReport, - isReportSettled, }); }); } @@ -246,7 +242,6 @@ class PopoverReportActionContextMenu extends React.Component { reportAction={this.state.reportAction} isArchivedRoom={this.state.isArchivedRoom} isChronosReport={this.state.isChronosReport} - isReportSettled={this.state.isReportSettled} anchor={this.contextMenuTargetNode} contentRef={this.setContentRef} /> @@ -278,7 +273,6 @@ class PopoverReportActionContextMenu extends React.Component { shouldSetModalVisibilityForDeleteConfirmation: true, isArchivedRoom: false, isChronosReport: false, - isReportSettled: false, }); } @@ -325,7 +319,6 @@ class PopoverReportActionContextMenu extends React.Component { draftMessage={this.state.reportActionDraftMessage} isArchivedRoom={this.state.isArchivedRoom} isChronosReport={this.state.isChronosReport} - isReportSettled={this.state.isReportSettled} anchor={this.contextMenuTargetNode} contentRef={this.contentRef} /> diff --git a/src/pages/home/report/ContextMenu/ReportActionContextMenu.js b/src/pages/home/report/ContextMenu/ReportActionContextMenu.js index c83549cabb81..df544f2e7202 100644 --- a/src/pages/home/report/ContextMenu/ReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/ReportActionContextMenu.js @@ -16,7 +16,6 @@ const contextMenuRef = React.createRef(); * @param {Function} [onHide=() => {}] - Run a callback when Menu is hidden * @param {Boolean} isArchivedRoom - Whether the provided report is an archived room * @param {Boolean} isChronosReport - Flag to check if the chat participant is Chronos - * @param {Boolean} isReportSettled - Whether the provided report has been reimbursed */ function showContextMenu( type, @@ -30,7 +29,6 @@ function showContextMenu( onHide = () => {}, isArchivedRoom = false, isChronosReport = false, - isReportSettled = false, ) { if (!contextMenuRef.current) { return; @@ -47,7 +45,6 @@ function showContextMenu( onHide, isArchivedRoom, isChronosReport, - isReportSettled, ); } diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 2fd07de1d8d6..8cb3bd38e12d 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -298,7 +298,6 @@ class ReportActionItem extends Component { } draftMessage={this.props.draftMessage} isChronosReport={ReportUtils.chatIncludesChronos(this.props.report)} - isReportSettled={this.props.iouReport.stateNum === CONST.REPORT.STATE_NUM.SUBMITTED} /> )} From 64de99fdd85801adce7267f567fa60fa9bd994e6 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 12 Apr 2023 15:00:49 +0200 Subject: [PATCH 08/22] get iouReport in isReimbursed --- src/libs/ReportUtils.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index e070cac6e76e..fd598580121a 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -156,8 +156,8 @@ function canEditReportAction(reportAction) { * @param {String} reportID * @returns {Boolean} */ -function isReportSettled(reportID) { - return allReports[reportID].status === CONST.REPORT.STATUS.REIMBURSED; +function isReimbursed(reportID) { + return allReports[`report_${reportID}`].status === CONST.REPORT.STATUS.REIMBURSED; } /** @@ -169,7 +169,7 @@ function isReportSettled(reportID) { function canDeleteReportAction(reportAction) { return reportAction.actorEmail === sessionEmail && (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT - || (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && !isReportSettled(reportAction.originalMessage.IOUReportID))) + || (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && !isReimbursed(reportAction.originalMessage.IOUReportID))) && reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; } @@ -1781,5 +1781,5 @@ export { getSmallSizeAvatar, getMoneyRequestOptions, canRequestMoney, - isReportSettled, + isReimbursed, }; From 1e45e0ff95c2c8653e3bc25650e2430a6c497e54 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 12 Apr 2023 15:16:31 +0200 Subject: [PATCH 09/22] use lodash --- src/libs/ReportUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index fd598580121a..d4e75bd91015 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -157,7 +157,7 @@ function canEditReportAction(reportAction) { * @returns {Boolean} */ function isReimbursed(reportID) { - return allReports[`report_${reportID}`].status === CONST.REPORT.STATUS.REIMBURSED; + return lodashGet(allReports, [`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, 'status'], '') === CONST.REPORT.STATUS.REIMBURSED; } /** From 8899cc8197060fc5bdff09c124223ebc1606d7b7 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 12 Apr 2023 19:13:38 +0200 Subject: [PATCH 10/22] rename method to isSettled, fix bug --- src/libs/ReportUtils.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index d4e75bd91015..e714cf7029f8 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -151,13 +151,13 @@ function canEditReportAction(reportAction) { } /** - * Returns whether the Money Request report has been reimbursed + * Whether the Money Request report has been reimbursed * * @param {String} reportID * @returns {Boolean} */ -function isReimbursed(reportID) { - return lodashGet(allReports, [`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, 'status'], '') === CONST.REPORT.STATUS.REIMBURSED; +function isSettled(reportID) { + return !lodashGet(allReports, [`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, 'hasOutstandingIOU']); } /** @@ -169,7 +169,7 @@ function isReimbursed(reportID) { function canDeleteReportAction(reportAction) { return reportAction.actorEmail === sessionEmail && (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT - || (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && !isReimbursed(reportAction.originalMessage.IOUReportID))) + || (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && !isSettled(reportAction.originalMessage.IOUReportID))) && reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; } @@ -1781,5 +1781,5 @@ export { getSmallSizeAvatar, getMoneyRequestOptions, canRequestMoney, - isReimbursed, + isSettled, }; From 7f1af583974d8a06ebeed04b460e11ae9140a503 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 12 Apr 2023 20:13:06 +0200 Subject: [PATCH 11/22] update confirmation modal --- src/languages/en.js | 4 ++-- src/languages/es.js | 4 ++-- src/pages/home/report/ContextMenu/ContextMenuActions.js | 2 +- .../home/report/ContextMenu/PopoverReportActionContextMenu.js | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index 1c83afdb79b7..b28020bb1b1f 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -239,8 +239,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: ({actionName}) => `Delete ${actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? 'request' : 'comment'}`, + deleteConfirmation: ({actionName}) => `Are you sure you want to delete this ${actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? 'request' : 'comment'}?`, }, emojiReactions: { addReactionTooltip: 'Add reaction', diff --git a/src/languages/es.js b/src/languages/es.js index 74dbcb762d50..c4a89223b350 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -238,8 +238,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: ({actionName}) => `Eliminar ${actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? 'pedido' : 'comentario'}`, + deleteConfirmation: ({actionName}) => `¿Estás seguro de que quieres eliminar este ${actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? 'pedido' : 'comentario'}`, }, emojiReactions: { addReactionTooltip: 'Añadir una reacción', diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.js b/src/pages/home/report/ContextMenu/ContextMenuActions.js index 385fee477f7b..50b4ec5e7082 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.js +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.js @@ -235,7 +235,7 @@ export default [ getDescription: () => {}, }, { - textTranslateKey: 'reportActionContextMenu.deleteComment', + textTranslateKey: 'reportActionContextMenu.deleteAction', icon: Expensicons.Trashcan, shouldShow: (type, reportAction, isArchivedRoom, betas, menuTarget, isChronosReport) => type === CONTEXT_MENU_TYPES.REPORT_ACTION && ReportUtils.canDeleteReportAction(reportAction) && !isArchivedRoom && !isChronosReport, diff --git a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js index 4883d2f37aa7..4553b6b5fb8e 100644 --- a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js @@ -324,13 +324,13 @@ class PopoverReportActionContextMenu extends React.Component { /> Date: Wed, 12 Apr 2023 20:16:07 +0200 Subject: [PATCH 12/22] rm reportAction reset on modal hide --- .../home/report/ContextMenu/PopoverReportActionContextMenu.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js index 4553b6b5fb8e..02f8582cab4d 100644 --- a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js @@ -268,7 +268,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, From bdf32e68eb1434fc29698f364ac8157ebd0cf930 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 12 Apr 2023 20:19:24 +0200 Subject: [PATCH 13/22] add api callback conditional --- .../report/ContextMenu/PopoverReportActionContextMenu.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js index 02f8582cab4d..8ba79910cad7 100644 --- a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js @@ -260,7 +260,12 @@ class PopoverReportActionContextMenu extends React.Component { confirmDeleteAndHideModal() { this.callbackWhenDeleteModalHide = () => this.onComfirmDeleteModal = this.runAndResetCallback(this.onComfirmDeleteModal); - Report.deleteReportComment(this.state.reportID, this.state.reportAction); + + if (this.state.reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU) { + // @TODO: Implement new DeleteMoneyRequest API command from issue https://github.com/Expensify/Expensify/issues/270502 + } else { + Report.deleteReportComment(this.state.reportID, this.state.reportAction); + } this.setState({isDeleteCommentConfirmModalVisible: false}); } From 3324de7c9816c50fcf20f0a29248fc7fc96cf53d Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Wed, 12 Apr 2023 20:28:49 +0200 Subject: [PATCH 14/22] update tooltip --- .../home/report/ContextMenu/BaseReportActionContextMenu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js index e562a417d423..6771ac18409c 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 ( Date: Sat, 15 Apr 2023 00:51:14 +0200 Subject: [PATCH 15/22] create isMoneyRequestAction and replace usages of const --- src/components/ReportTransaction.js | 3 ++- src/libs/IOUUtils.js | 3 ++- src/libs/ReportActionsUtils.js | 9 +++++++++ src/libs/ReportUtils.js | 2 +- .../report/ContextMenu/PopoverReportActionContextMenu.js | 3 ++- src/pages/home/report/ReportActionItem.js | 5 +++-- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/components/ReportTransaction.js b/src/components/ReportTransaction.js index be53b11c742e..ce8079dbe35f 100644 --- a/src/components/ReportTransaction.js +++ b/src/components/ReportTransaction.js @@ -11,6 +11,7 @@ import withLocalize, {withLocalizePropTypes} from './withLocalize'; import OfflineWithFeedback from './OfflineWithFeedback'; import Text from './Text'; import Button from './Button'; +import * as ReportActionsUtils from '../libs/ReportActionsUtils'; const propTypes = { /** The chatReport which the transaction is associated with */ @@ -57,7 +58,7 @@ class ReportTransaction extends Component { return ( { - if (this.props.action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU) { + if (ReportActionsUtils.isMoneyRequestAction(this.props.action)) { ReportActions.clearSendMoneyErrors(this.props.chatReportID, this.props.action.reportActionID); } if (this.props.action.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD) { diff --git a/src/libs/IOUUtils.js b/src/libs/IOUUtils.js index b4e8f1ff46ce..1fa76ef798c5 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 @@ -81,7 +82,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 + && 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)) diff --git a/src/libs/ReportActionsUtils.js b/src/libs/ReportActionsUtils.js index b4c4009d6650..c6b049aac5fa 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 reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU; +} + /** * Sort an array of reportActions by their created timestamp first, and reportActionID second * This gives us a stable order even in the case of multiple reportActions created on the same millisecond @@ -254,4 +262,5 @@ export { getSortedReportActionsForDisplay, getLastClosedReportAction, getLatestReportActionFromOnyxData, + isMoneyRequestAction, }; diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index e714cf7029f8..9157cfde25c2 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -169,7 +169,7 @@ function isSettled(reportID) { function canDeleteReportAction(reportAction) { return reportAction.actorEmail === sessionEmail && (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT - || (reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU && !isSettled(reportAction.originalMessage.IOUReportID))) + || (ReportActionsUtils.isMoneyRequestAction(reportAction) && !isSettled(reportAction.originalMessage.IOUReportID))) && reportAction.pendingAction !== CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE; } diff --git a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js index 8ba79910cad7..4412c151a8bd 100644 --- a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js @@ -10,6 +10,7 @@ import PopoverWithMeasuredContent from '../../../../components/PopoverWithMeasur import BaseReportActionContextMenu from './BaseReportActionContextMenu'; import ConfirmModal from '../../../../components/ConfirmModal'; import CONST from '../../../../CONST'; +import * as ReportActionsUtils from '../../../../libs/ReportActionsUtils'; const propTypes = { ...withLocalizePropTypes, @@ -261,7 +262,7 @@ class PopoverReportActionContextMenu extends React.Component { confirmDeleteAndHideModal() { this.callbackWhenDeleteModalHide = () => this.onComfirmDeleteModal = this.runAndResetCallback(this.onComfirmDeleteModal); - if (this.state.reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU) { + if (ReportActionsUtils.isMoneyRequestAction(this.state.reportAction)) { // @TODO: Implement new DeleteMoneyRequest API command from issue https://github.com/Expensify/Expensify/issues/270502 } else { Report.deleteReportComment(this.state.reportID, this.state.reportAction); diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 8cb3bd38e12d..a2ec77930c2f 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -33,6 +33,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'; @@ -156,7 +157,7 @@ class ReportActionItem extends Component { */ renderItemContent(hovered = false) { let children; - if (this.props.action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU) { + if (ReportActionsUtils.isMoneyRequestAction(this.props.action)) { children = ( {!this.props.displayAsGroup ? ( From 556c961525f61d53356319b6238df11d6800d901 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Sat, 15 Apr 2023 00:54:05 +0200 Subject: [PATCH 16/22] use isMoneyRequestAction in other places --- src/languages/en.js | 5 +++-- src/languages/es.js | 5 +++-- .../report/ContextMenu/PopoverReportActionContextMenu.js | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/languages/en.js b/src/languages/en.js index b28020bb1b1f..e9615f5ea077 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 { @@ -239,8 +240,8 @@ export default { copyEmailToClipboard: 'Copy email to clipboard', markAsUnread: 'Mark as unread', editComment: 'Edit comment', - deleteAction: ({actionName}) => `Delete ${actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? 'request' : 'comment'}`, - deleteConfirmation: ({actionName}) => `Are you sure you want to delete this ${actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? 'request' : 'comment'}?`, + deleteAction: ({action}) => `Delete ${ReportActionsUtils.isMoneyRequestAction(action) ? 'request' : 'comment'}`, + deleteConfirmation: ({action}) => `Are you sure you want to delete this ${ReportActionsUtils.isMoneyRequestAction(action) ? 'request' : 'comment'}?`, }, emojiReactions: { addReactionTooltip: 'Add reaction', diff --git a/src/languages/es.js b/src/languages/es.js index c4a89223b350..d43bd8ad69db 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 { @@ -238,8 +239,8 @@ export default { copyEmailToClipboard: 'Copiar email al portapapeles', markAsUnread: 'Marcar como no leído', editComment: 'Editar comentario', - deleteAction: ({actionName}) => `Eliminar ${actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? 'pedido' : 'comentario'}`, - deleteConfirmation: ({actionName}) => `¿Estás seguro de que quieres eliminar este ${actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? 'pedido' : 'comentario'}`, + deleteAction: ({action}) => `Eliminar ${ReportActionsUtils.isMoneyRequestAction(action) ? 'pedido' : 'comentario'}`, + deleteConfirmation: ({action}) => `¿Estás seguro de que quieres eliminar este ${ReportActionsUtils.isMoneyRequestAction(action) ? 'pedido' : 'comentario'}`, }, emojiReactions: { addReactionTooltip: 'Añadir una reacción', diff --git a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js index 4412c151a8bd..80a3bedf4706 100644 --- a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js @@ -329,13 +329,13 @@ class PopoverReportActionContextMenu extends React.Component { /> Date: Sat, 15 Apr 2023 01:00:37 +0200 Subject: [PATCH 17/22] fix undefined error --- src/libs/ReportActionsUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/ReportActionsUtils.js b/src/libs/ReportActionsUtils.js index c6b049aac5fa..e395ac33bd17 100644 --- a/src/libs/ReportActionsUtils.js +++ b/src/libs/ReportActionsUtils.js @@ -45,7 +45,7 @@ function isDeletedAction(reportAction) { * @returns {Boolean} */ function isMoneyRequestAction(reportAction) { - return reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.IOU; + return lodashGet(reportAction, 'actionName', '') === CONST.REPORT.ACTIONS.TYPE.IOU; } /** From a241b2b57c6952706fe507a0fa2151cd124533a6 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Sat, 13 May 2023 15:50:04 +0100 Subject: [PATCH 18/22] resolve conflicts --- ios/Podfile.lock | 2 +- src/libs/IOUUtils.js | 10 ++++------ src/libs/ReportUtils.js | 10 ++++++---- .../report/ContextMenu/BaseReportActionContextMenu.js | 11 +++++------ .../ContextMenu/PopoverReportActionContextMenu.js | 2 +- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index fc30bf617a24..5d87e4944452 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1129,4 +1129,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 5feaab251246f42f41e69c8a28fa331b4899e814 -COCOAPODS: 1.12.0 +COCOAPODS: 1.12.1 diff --git a/src/libs/IOUUtils.js b/src/libs/IOUUtils.js index 28418fffbde6..9fa25dfe3512 100644 --- a/src/libs/IOUUtils.js +++ b/src/libs/IOUUtils.js @@ -75,12 +75,10 @@ function updateIOUOwnerAndTotal(iouReport, actorEmail, amount, currency, type = */ function getIOUReportActions(reportActions, iouReport, type = '', pendingAction = '', filterRequestsInDifferentCurrency = false) { return _.chain(reportActions) - .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)) + .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)) .value(); } diff --git a/src/libs/ReportUtils.js b/src/libs/ReportUtils.js index f8bc19d49c4d..c3707e0f7c94 100644 --- a/src/libs/ReportUtils.js +++ b/src/libs/ReportUtils.js @@ -200,10 +200,12 @@ function isSettled(reportID) { * @returns {Boolean} */ function canDeleteReportAction(reportAction) { - return reportAction.actorEmail === sessionEmail - && ((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; + return ( + reportAction.actorEmail === sessionEmail && + ((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 ec2f2940c22f..49f8ac8aa421 100755 --- a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js @@ -84,9 +84,7 @@ class BaseReportActionContextMenu extends React.Component { icon={contextAction.icon} text={this.props.translate(contextAction.textTranslateKey, {actionName: this.props.reportAction.actionName})} successIcon={contextAction.successIcon} - successText={contextAction.successTextTranslateKey - ? this.props.translate(contextAction.successTextTranslateKey) - : undefined} + successText={contextAction.successTextTranslateKey ? this.props.translate(contextAction.successTextTranslateKey) : undefined} isMini={this.props.isMini} key={contextAction.textTranslateKey} onPress={() => contextAction.onPress(closePopup, payload)} @@ -94,9 +92,10 @@ class BaseReportActionContextMenu extends React.Component { autoReset={contextAction.autoReset} /> ); - })} - - )); + })} + + ) + ); } } diff --git a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js index a48d800fe14f..a160192306c1 100644 --- a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js @@ -249,7 +249,7 @@ class PopoverReportActionContextMenu extends React.Component { } confirmDeleteAndHideModal() { - this.callbackWhenDeleteModalHide = () => this.onComfirmDeleteModal = this.runAndResetCallback(this.onComfirmDeleteModal); + this.callbackWhenDeleteModalHide = () => (this.onComfirmDeleteModal = this.runAndResetCallback(this.onComfirmDeleteModal)); if (ReportActionsUtils.isMoneyRequestAction(this.state.reportAction)) { IOU.deleteReportComment(this.state.reportID, this.state.reportAction); From eb36561477b07a1768a74baa45be821bc25d0afd Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Sat, 13 May 2023 15:53:14 +0100 Subject: [PATCH 19/22] revert podfile change --- ios/Podfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 5d87e4944452..fc30bf617a24 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -1129,4 +1129,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 5feaab251246f42f41e69c8a28fa331b4899e814 -COCOAPODS: 1.12.1 +COCOAPODS: 1.12.0 From d60a888cc728a1bac0a024297c6e8d350bd73c42 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Sat, 13 May 2023 15:59:34 +0100 Subject: [PATCH 20/22] add delete call --- .../report/ContextMenu/PopoverReportActionContextMenu.js | 1 - src/pages/home/report/ReportActionItem.js | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js index 08c2e3738cb0..10e511ca4456 100644 --- a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js @@ -254,7 +254,6 @@ class PopoverReportActionContextMenu extends React.Component { if (ReportActionsUtils.isMoneyRequestAction(this.state.reportAction)) { IOU.deleteReportComment(this.state.reportID, this.state.reportAction); - // @TODO: Implement new DeleteMoneyRequest API command from issue https://github.com/Expensify/Expensify/issues/270502 } else { Report.deleteReportComment(this.state.reportID, this.state.reportAction); } diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index 6452f3e7ae0e..9abff775f2aa 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -49,7 +49,6 @@ import DisplayNames from '../../../components/DisplayNames'; import personalDetailsPropType from '../../personalDetailsPropType'; import ReportActionItemDraft from './ReportActionItemDraft'; import TaskPreview from '../../../components/ReportActionItem/TaskPreview'; -import * as ReportActionUtils from '../../../libs/ReportActionsUtils'; import Permissions from '../../../libs/Permissions'; const propTypes = { @@ -185,14 +184,10 @@ class ReportActionItem extends Component { */ renderItemContent(hovered = false) { let children; -<<<<<<< HEAD if (ReportActionsUtils.isMoneyRequestAction(this.props.action)) { -======= - if (this.props.action.actionName === CONST.REPORT.ACTIONS.TYPE.IOU) { // There is no single iouReport for bill splits, so only 1:1 requests require an iouReportID const iouReportID = this.props.action.originalMessage.IOUReportID ? this.props.action.originalMessage.IOUReportID.toString() : '0'; ->>>>>>> main children = ( ); - } else if (ReportActionUtils.isCreatedTaskReportAction(this.props.action)) { + } else if (ReportActionsUtils.isCreatedTaskReportAction(this.props.action)) { children = ( Date: Sat, 13 May 2023 16:24:12 +0100 Subject: [PATCH 21/22] fix function call --- .../home/report/ContextMenu/PopoverReportActionContextMenu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js index 10e511ca4456..dfdf559e79c7 100644 --- a/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js +++ b/src/pages/home/report/ContextMenu/PopoverReportActionContextMenu.js @@ -253,7 +253,7 @@ class PopoverReportActionContextMenu extends React.Component { this.callbackWhenDeleteModalHide = () => (this.onComfirmDeleteModal = this.runAndResetCallback(this.onComfirmDeleteModal)); if (ReportActionsUtils.isMoneyRequestAction(this.state.reportAction)) { - IOU.deleteReportComment(this.state.reportID, 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); } From 64e23125079bef9b509fb0b32adc181a44e8d44b Mon Sep 17 00:00:00 2001 From: Vit Horacek <36083550+mountiny@users.noreply.github.com> Date: Tue, 16 May 2023 11:22:30 +0200 Subject: [PATCH 22/22] Update src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js Co-authored-by: Fedi Rajhi --- .../home/report/ContextMenu/BaseReportActionContextMenu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js b/src/pages/home/report/ContextMenu/BaseReportActionContextMenu.js index b164df3881ba..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 (