Skip to content

Commit

Permalink
remove unuse function
Browse files Browse the repository at this point in the history
  • Loading branch information
dukenv0307 committed Apr 3, 2024
1 parent 3bf9d57 commit 7cfe354
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 44 deletions.
3 changes: 1 addition & 2 deletions src/components/ReportActionItem/MoneyRequestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -481,7 +480,7 @@ function MoneyRequestView({
accessibilityLabel={translate('common.billable')}
isOn={!!transactionBillable}
onToggle={saveBillable}
interactive={canEditBillable}
interactive={canEdit}
/>
</View>
)}
Expand Down
42 changes: 0 additions & 42 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2371,47 +2371,6 @@ function canEditMoneyRequest(reportAction: OnyxEntry<ReportAction>): boolean {
return !isReportApproved(moneyRequestReport) && !isSettled(moneyRequestReport?.reportID) && isRequestor;
}

function canEditBillable(reportAction: OnyxEntry<ReportAction>): 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
*
Expand Down Expand Up @@ -5938,7 +5897,6 @@ export {
canEditRoomVisibility,
canEditPolicyDescription,
getPolicyDescriptionText,
canEditBillable,
getDefaultGroupAvatar,
isAllowedToSubmitDraftExpenseReport,
isAllowedToApproveExpenseReport,
Expand Down

0 comments on commit 7cfe354

Please sign in to comment.