From 7cfe354d41379b71a3bb6face50cc132300641f0 Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 3 Apr 2024 11:46:40 +0700 Subject: [PATCH] remove unuse function --- .../ReportActionItem/MoneyRequestView.tsx | 3 +- src/libs/ReportUtils.ts | 42 ------------------- 2 files changed, 1 insertion(+), 44 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 2a6f4c256ea8..613bdd442eef 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -143,7 +143,6 @@ function MoneyRequestView({ const canEditDate = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DATE); const canEditReceipt = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.RECEIPT); const canEditDistance = ReportUtils.canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.DISTANCE); - const canEditBillable = ReportUtils.canEditBillable(parentReportAction); // A flag for verifying that the current report is a sub-report of a workspace chat // if the policy of the report is either Collect or Control, then this report must be tied to workspace chat @@ -481,7 +480,7 @@ function MoneyRequestView({ accessibilityLabel={translate('common.billable')} isOn={!!transactionBillable} onToggle={saveBillable} - interactive={canEditBillable} + interactive={canEdit} /> )} diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a29ef88ef646..8296e38411be 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -2371,47 +2371,6 @@ function canEditMoneyRequest(reportAction: OnyxEntry): boolean { return !isReportApproved(moneyRequestReport) && !isSettled(moneyRequestReport?.reportID) && isRequestor; } -function canEditBillable(reportAction: OnyxEntry): boolean { - const isDeleted = ReportActionsUtils.isDeletedAction(reportAction); - - if (isDeleted) { - return false; - } - - // If the report action is not IOU type, return true early - if (reportAction?.actionName !== CONST.REPORT.ACTIONS.TYPE.IOU) { - return true; - } - - if (reportAction.originalMessage.type !== CONST.IOU.REPORT_ACTION_TYPE.CREATE) { - return false; - } - - const moneyRequestReportID = reportAction?.originalMessage?.IOUReportID ?? 0; - - if (!moneyRequestReportID) { - return false; - } - - const moneyRequestReport = getReport(String(moneyRequestReportID)); - const isRequestor = currentUserAccountID === reportAction?.actorAccountID; - - if (isIOUReport(moneyRequestReport)) { - return isProcessingReport(moneyRequestReport) && isRequestor; - } - - const policy = getPolicy(moneyRequestReport?.policyID ?? ''); - const isAdmin = policy.role === CONST.POLICY.ROLE.ADMIN; - const isManager = currentUserAccountID === moneyRequestReport?.managerID; - - // Admin & managers can always edit coding fields such as tag, category, billable, etc. As long as the report has a state higher than OPEN. - if ((isAdmin || isManager) && !isOpenExpenseReport(moneyRequestReport)) { - return true; - } - - return !isReportApproved(moneyRequestReport) && !isSettled(moneyRequestReport?.reportID) && isRequestor; -} - /** * Checks if the current user can edit the provided property of a money request * @@ -5938,7 +5897,6 @@ export { canEditRoomVisibility, canEditPolicyDescription, getPolicyDescriptionText, - canEditBillable, getDefaultGroupAvatar, isAllowedToSubmitDraftExpenseReport, isAllowedToApproveExpenseReport,