From fd4a11506d75c07dbe321e398c43f2e7e6023818 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 20 Jun 2024 17:30:05 +0800 Subject: [PATCH 1/2] fix can delete paid workspace track expense --- src/components/MoneyReportHeader.tsx | 3 +-- src/components/MoneyRequestHeader.tsx | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/MoneyReportHeader.tsx b/src/components/MoneyReportHeader.tsx index 90952157f179..5c71e80f0abb 100644 --- a/src/components/MoneyReportHeader.tsx +++ b/src/components/MoneyReportHeader.tsx @@ -80,8 +80,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea // Only the requestor can delete the request, admins can only edit it. const isActionOwner = typeof requestParentReportAction?.actorAccountID === 'number' && typeof session?.accountID === 'number' && requestParentReportAction.actorAccountID === session?.accountID; - const canDeleteRequest = - isActionOwner && (ReportUtils.canAddOrDeleteTransactions(moneyRequestReport) || ReportUtils.isTrackExpenseReport(transactionThreadReport)) && !isDeletedParentAction; + const canDeleteRequest = isActionOwner && ReportUtils.canAddOrDeleteTransactions(moneyRequestReport) && !isDeletedParentAction; const [isHoldMenuVisible, setIsHoldMenuVisible] = useState(false); const [paymentType, setPaymentType] = useState(); const [requestType, setRequestType] = useState(); diff --git a/src/components/MoneyRequestHeader.tsx b/src/components/MoneyRequestHeader.tsx index f14fe11f5d74..9d6ed294e173 100644 --- a/src/components/MoneyRequestHeader.tsx +++ b/src/components/MoneyRequestHeader.tsx @@ -61,7 +61,8 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow const {translate} = useLocalize(); const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false); const [shouldShowHoldMenu, setShouldShowHoldMenu] = useState(false); - const moneyRequestReport = parentReport; + const isSelfDMTrack = ReportUtils.isTrackExpenseReport(report) && ReportUtils.isSelfDM(parentReport); + const moneyRequestReport = !isSelfDMTrack ? parentReport : undefined; const isSettled = ReportUtils.isSettled(moneyRequestReport?.reportID); const isApproved = ReportUtils.isReportApproved(moneyRequestReport); const isDraft = ReportUtils.isOpenExpenseReport(moneyRequestReport); @@ -101,7 +102,7 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow const canHoldOrUnholdRequest = !isSettled && !isApproved && !isDeletedParentAction && !ReportUtils.isArchivedRoom(parentReport); // If the report supports adding transactions to it, then it also supports deleting transactions from it. - const canDeleteRequest = isActionOwner && (ReportUtils.canAddOrDeleteTransactions(moneyRequestReport) || ReportUtils.isTrackExpenseReport(report)) && !isDeletedParentAction; + const canDeleteRequest = isActionOwner && (ReportUtils.canAddOrDeleteTransactions(moneyRequestReport) || isSelfDMTrack) && !isDeletedParentAction; const changeMoneyRequestStatus = () => { const iouTransactionID = parentReportAction?.actionName === CONST.REPORT.ACTIONS.TYPE.IOU ? parentReportAction.originalMessage?.IOUTransactionID ?? '-1' : '-1'; From a2ad4adcff4fed9a473a0d9a7ab0fddb0db6e5b4 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Wed, 26 Jun 2024 10:58:00 +0800 Subject: [PATCH 2/2] update variable name --- src/components/MoneyRequestHeader.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/MoneyRequestHeader.tsx b/src/components/MoneyRequestHeader.tsx index 82d8499d9274..d55d3cc19fe9 100644 --- a/src/components/MoneyRequestHeader.tsx +++ b/src/components/MoneyRequestHeader.tsx @@ -64,8 +64,8 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow const {translate} = useLocalize(); const [isDeleteModalVisible, setIsDeleteModalVisible] = useState(false); const [shouldShowHoldMenu, setShouldShowHoldMenu] = useState(false); - const isSelfDMTrack = ReportUtils.isTrackExpenseReport(report) && ReportUtils.isSelfDM(parentReport); - const moneyRequestReport = !isSelfDMTrack ? parentReport : undefined; + const isSelfDMTrackExpenseReport = ReportUtils.isTrackExpenseReport(report) && ReportUtils.isSelfDM(parentReport); + const moneyRequestReport = !isSelfDMTrackExpenseReport ? parentReport : undefined; const isSettled = ReportUtils.isSettled(moneyRequestReport?.reportID); const isApproved = ReportUtils.isReportApproved(moneyRequestReport); const isDraft = ReportUtils.isOpenExpenseReport(moneyRequestReport); @@ -104,7 +104,7 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow const canHoldOrUnholdRequest = !isSettled && !isApproved && !isDeletedParentAction && !ReportUtils.isArchivedRoom(parentReport); // If the report supports adding transactions to it, then it also supports deleting transactions from it. - const canDeleteRequest = isActionOwner && (ReportUtils.canAddOrDeleteTransactions(moneyRequestReport) || isSelfDMTrack) && !isDeletedParentAction; + const canDeleteRequest = isActionOwner && (ReportUtils.canAddOrDeleteTransactions(moneyRequestReport) || isSelfDMTrackExpenseReport) && !isDeletedParentAction; const changeMoneyRequestStatus = () => { const iouTransactionID = ReportActionsUtils.isMoneyRequestAction(parentReportAction) ? ReportActionsUtils.getOriginalMessage(parentReportAction)?.IOUTransactionID ?? '-1' : '-1';