From f496decb39d86759247e2e6d84bb909c71c837e5 Mon Sep 17 00:00:00 2001 From: daledah Date: Thu, 22 May 2025 05:26:59 +0700 Subject: [PATCH] revert: add reimbursable toggle to create expense flow --- src/CONST.ts | 1 - .../MoneyRequestConfirmationList.tsx | 10 --- .../MoneyRequestConfirmationListFooter.tsx | 29 ------- .../ReportActionItem/MoneyRequestView.tsx | 32 +------ .../parameters/CreateDistanceRequestParams.ts | 1 - .../parameters/CreatePerDiemRequestParams.ts | 1 - src/libs/API/parameters/RequestMoneyParams.ts | 2 +- src/libs/API/parameters/SplitBillParams.ts | 1 - .../API/parameters/StartSplitBillParams.ts | 1 - src/libs/API/types.ts | 2 - src/libs/ModifiedExpenseMessage.ts | 11 ++- src/libs/ReportUtils.ts | 9 -- src/libs/TransactionUtils/index.ts | 7 +- src/libs/actions/IOU.ts | 84 ++++--------------- src/libs/actions/Policy/Policy.ts | 6 +- .../step/IOURequestStepConfirmation.tsx | 23 ----- .../request/step/IOURequestStepDistance.tsx | 1 - src/types/onyx/Policy.ts | 3 - 18 files changed, 30 insertions(+), 194 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 3fec3eb28b2..0e6c66c297f 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -3735,7 +3735,6 @@ const CONST = { TAG: 'tag', TAX_RATE: 'taxRate', TAX_AMOUNT: 'taxAmount', - REIMBURSABLE: 'reimbursable', REPORT: 'report', }, FOOTER: { diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index cf445a7783c..129e205a1ce 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -179,12 +179,6 @@ type MoneyRequestConfirmationListProps = { /** The PDF password callback */ onPDFPassword?: () => void; - - /** Function to toggle reimbursable */ - onToggleReimbursable?: (isOn: boolean) => void; - - /** Flag indicating if the IOU is reimbursable */ - iouIsReimbursable?: boolean; }; type MoneyRequestConfirmationListItem = Participant | OptionData; @@ -225,8 +219,6 @@ function MoneyRequestConfirmationList({ isConfirming, onPDFLoadError, onPDFPassword, - iouIsReimbursable = true, - onToggleReimbursable, }: MoneyRequestConfirmationListProps) { const [policyCategoriesReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`, {canBeMissing: true}); const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`, {canBeMissing: true}); @@ -1085,8 +1077,6 @@ function MoneyRequestConfirmationList({ unit={unit} onPDFLoadError={onPDFLoadError} onPDFPassword={onPDFPassword} - iouIsReimbursable={iouIsReimbursable} - onToggleReimbursable={onToggleReimbursable} isReceiptEditable={isReceiptEditable} /> ); diff --git a/src/components/MoneyRequestConfirmationListFooter.tsx b/src/components/MoneyRequestConfirmationListFooter.tsx index cc6401dde66..15b5cf32d0b 100644 --- a/src/components/MoneyRequestConfirmationListFooter.tsx +++ b/src/components/MoneyRequestConfirmationListFooter.tsx @@ -25,7 +25,6 @@ import { getTaxAmount, getTaxName, isAmountMissing, - isCardTransaction, isCreatedMissing, isFetchingWaypointsFromServer, shouldShowAttendees as shouldShowAttendeesTransactionUtils, @@ -197,12 +196,6 @@ type MoneyRequestConfirmationListFooterProps = { /** The PDF password callback */ onPDFPassword?: () => void; - - /** Function to toggle reimbursable */ - onToggleReimbursable?: (isOn: boolean) => void; - - /** Flag indicating if the IOU is reimbursable */ - iouIsReimbursable: boolean; }; function MoneyRequestConfirmationListFooter({ @@ -253,8 +246,6 @@ function MoneyRequestConfirmationListFooter({ unit, onPDFLoadError, onPDFPassword, - iouIsReimbursable, - onToggleReimbursable, isReceiptEditable = false, }: MoneyRequestConfirmationListFooterProps) { const styles = useThemeStyles(); @@ -321,7 +312,6 @@ function MoneyRequestConfirmationListFooter({ const canModifyTaxFields = !isReadOnly && !isDistanceRequest && !isPerDiemRequest; // A flag for showing the billable field const shouldShowBillable = policy?.disabledFields?.defaultBillable === false; - const shouldShowReimbursable = policy?.disabledFields?.reimbursable === false && !isCardTransaction(transaction); // Do not hide fields in case of paying someone const shouldShowAllFields = !!isPerDiemRequest || !!isDistanceRequest || shouldExpandFields || !shouldShowSmartScanFields || isTypeSend || !!isEditingSplitBill; // Calculate the formatted tax amount based on the transaction's tax amount and the IOU currency code @@ -646,25 +636,6 @@ function MoneyRequestConfirmationListFooter({ shouldShow: shouldShowAttendees, isSupplementary: true, }, - { - item: ( - - onToggleReimbursable?.(isOn)} - isActive={iouIsReimbursable} - disabled={isReadOnly} - wrapperStyle={styles.flex1} - /> - - ), - shouldShow: shouldShowReimbursable, - isSupplementary: true, - }, { item: ( shouldShowAttendeesTransactionUtils(iouType, policy), [iouType, policy]); const shouldShowTax = isTaxTrackingEnabled(isPolicyExpenseChat, policy, isDistanceRequest, isPerDiemRequest); @@ -285,17 +279,6 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals [transaction, report, policy, policyTagList, policyCategories], ); - const saveReimbursable = useCallback( - (newReimbursable: boolean) => { - // If the value hasn't changed, don't request to save changes on the server and just close the modal - if (newReimbursable === getReimbursable(transaction) || !transaction?.transactionID || !report?.reportID) { - return; - } - updateMoneyRequestReimbursable(transaction.transactionID, report?.reportID, newReimbursable, policy, policyTagList, policyCategories); - }, - [transaction, report, policy, policyTagList, policyCategories], - ); - if (isCardTransaction) { if (transactionPostedDate) { dateDescription += ` ${CONST.DOT_SEPARATOR} ${translate('iou.posted')} ${transactionPostedDate}`; @@ -817,19 +800,6 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals /> )} - {shouldShowReimbursable && ( - - - {Str.UCFirst(translate('iou.reimbursable'))} - - - - )} {/* Note: "Billable" toggle and "View trip details" should be always the last two items */} {shouldShowBillable && ( diff --git a/src/libs/API/parameters/CreateDistanceRequestParams.ts b/src/libs/API/parameters/CreateDistanceRequestParams.ts index 738393903c3..73f08deb6c4 100644 --- a/src/libs/API/parameters/CreateDistanceRequestParams.ts +++ b/src/libs/API/parameters/CreateDistanceRequestParams.ts @@ -15,7 +15,6 @@ type CreateDistanceRequestParams = { taxCode?: string; taxAmount?: number; billable?: boolean; - reimbursable?: boolean; transactionThreadReportID?: string; createdReportActionIDForThread?: string; payerEmail?: string; diff --git a/src/libs/API/parameters/CreatePerDiemRequestParams.ts b/src/libs/API/parameters/CreatePerDiemRequestParams.ts index 85ff52eadaf..480acd9ca23 100644 --- a/src/libs/API/parameters/CreatePerDiemRequestParams.ts +++ b/src/libs/API/parameters/CreatePerDiemRequestParams.ts @@ -20,7 +20,6 @@ type CreatePerDiemRequestParams = { transactionThreadReportID: string; createdReportActionIDForThread: string | undefined; billable?: boolean; - reimbursable?: boolean; attendees?: string; }; diff --git a/src/libs/API/parameters/RequestMoneyParams.ts b/src/libs/API/parameters/RequestMoneyParams.ts index d059aec8e59..74a435600cd 100644 --- a/src/libs/API/parameters/RequestMoneyParams.ts +++ b/src/libs/API/parameters/RequestMoneyParams.ts @@ -27,7 +27,7 @@ type RequestMoneyParams = { receiptGpsPoints?: string; transactionThreadReportID: string; createdReportActionIDForThread: string | undefined; - reimbursable?: boolean; + reimbursible?: boolean; description?: string; attendees?: string; }; diff --git a/src/libs/API/parameters/SplitBillParams.ts b/src/libs/API/parameters/SplitBillParams.ts index bc99bf176e2..3fda11b9ca9 100644 --- a/src/libs/API/parameters/SplitBillParams.ts +++ b/src/libs/API/parameters/SplitBillParams.ts @@ -9,7 +9,6 @@ type SplitBillParams = { category: string; tag: string; billable: boolean; - reimbursable: boolean; transactionID: string; reportActionID: string; createdReportActionID?: string; diff --git a/src/libs/API/parameters/StartSplitBillParams.ts b/src/libs/API/parameters/StartSplitBillParams.ts index 031d75aca52..10f1029a0fb 100644 --- a/src/libs/API/parameters/StartSplitBillParams.ts +++ b/src/libs/API/parameters/StartSplitBillParams.ts @@ -13,7 +13,6 @@ type StartSplitBillParams = { isFromGroupDM: boolean; createdReportActionID?: string; billable: boolean; - reimbursable: boolean; chatType?: string; taxCode?: string; taxAmount?: number; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 24b4ac39d40..20ee87018e5 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -188,7 +188,6 @@ const WRITE_COMMANDS = { COMPLETE_SPLIT_BILL: 'CompleteSplitBill', UPDATE_MONEY_REQUEST_ATTENDEES: 'UpdateMoneyRequestAttendees', UPDATE_MONEY_REQUEST_DATE: 'UpdateMoneyRequestDate', - UPDATE_MONEY_REQUEST_REIMBURSABLE: 'UpdateMoneyRequestReimbursable', UPDATE_MONEY_REQUEST_BILLABLE: 'UpdateMoneyRequestBillable', UPDATE_MONEY_REQUEST_MERCHANT: 'UpdateMoneyRequestMerchant', UPDATE_MONEY_REQUEST_TAG: 'UpdateMoneyRequestTag', @@ -656,7 +655,6 @@ type WriteCommandParameters = { [WRITE_COMMANDS.UPDATE_MONEY_REQUEST_ATTENDEES]: Parameters.UpdateMoneyRequestParams; [WRITE_COMMANDS.UPDATE_MONEY_REQUEST_DATE]: Parameters.UpdateMoneyRequestParams; [WRITE_COMMANDS.UPDATE_MONEY_REQUEST_MERCHANT]: Parameters.UpdateMoneyRequestParams; - [WRITE_COMMANDS.UPDATE_MONEY_REQUEST_REIMBURSABLE]: Parameters.UpdateMoneyRequestParams; [WRITE_COMMANDS.UPDATE_MONEY_REQUEST_BILLABLE]: Parameters.UpdateMoneyRequestParams; [WRITE_COMMANDS.UPDATE_MONEY_REQUEST_TAG]: Parameters.UpdateMoneyRequestParams; [WRITE_COMMANDS.UPDATE_MONEY_REQUEST_TAX_AMOUNT]: Parameters.UpdateMoneyRequestParams; diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index 0f438053f80..c4a9028118d 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -36,6 +36,13 @@ Onyx.connect({ callback: (value) => (allReports = value), }); +/** + * Utility to get message based on boolean literal value. + */ +function getBooleanLiteralMessage(value: string | undefined, truthyMessage: string, falsyMessage: string): string { + return value === 'true' ? truthyMessage : falsyMessage; +} + /** * Builds the partial message fragment for a modified field on the expense. */ @@ -327,8 +334,8 @@ function getForReportAction({ const hasModifiedReimbursable = isReportActionOriginalMessageAnObject && 'oldReimbursable' in reportActionOriginalMessage && 'reimbursable' in reportActionOriginalMessage; if (hasModifiedReimbursable) { buildMessageFragmentForValue( - reportActionOriginalMessage?.reimbursable ?? '', - reportActionOriginalMessage?.oldReimbursable ?? '', + getBooleanLiteralMessage(reportActionOriginalMessage?.reimbursable, translateLocal('iou.reimbursable'), translateLocal('iou.nonReimbursable')), + getBooleanLiteralMessage(reportActionOriginalMessage?.oldReimbursable, translateLocal('iou.reimbursable'), translateLocal('iou.nonReimbursable')), translateLocal('iou.expense'), true, setFragments, diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index da7ebb76820..a3cc452eb77 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -660,7 +660,6 @@ type TransactionDetails = { customUnitRateID?: string; comment: string; category: string; - reimbursable: boolean; billable: boolean; tag: string; mccGroup?: ValueOf; @@ -3734,7 +3733,6 @@ function getTransactionDetails( waypoints: getWaypoints(transaction), customUnitRateID: getRateID(transaction), category: getCategory(transaction), - reimbursable: getReimbursable(transaction), billable: getBillable(transaction), tag: getTag(transaction), mccGroup: getMCCGroup(transaction), @@ -3838,7 +3836,6 @@ function canEditFieldOfMoneyRequest(reportAction: OnyxInputOrEntry CONST.EDIT_REQUEST_FIELD.RECEIPT, CONST.EDIT_REQUEST_FIELD.DISTANCE, CONST.EDIT_REQUEST_FIELD.DISTANCE_RATE, - CONST.EDIT_REQUEST_FIELD.REIMBURSABLE, CONST.EDIT_REQUEST_FIELD.REPORT, ]; @@ -4380,12 +4377,6 @@ function getModifiedExpenseOriginalMessage( originalMessage.currency = getCurrency(oldTransaction); } - if ('reimbursable' in transactionChanges) { - const oldReimbursable = getReimbursable(oldTransaction); - originalMessage.oldReimbursable = oldReimbursable ? translateLocal('common.reimbursable').toLowerCase() : translateLocal('iou.nonReimbursable').toLowerCase(); - originalMessage.reimbursable = transactionChanges?.reimbursable ? translateLocal('common.reimbursable').toLowerCase() : translateLocal('iou.nonReimbursable').toLowerCase(); - } - if ('billable' in transactionChanges) { const oldBillable = getBillable(oldTransaction); originalMessage.oldBillable = oldBillable ? translateLocal('common.billable').toLowerCase() : translateLocal('common.nonBillable').toLowerCase(); diff --git a/src/libs/TransactionUtils/index.ts b/src/libs/TransactionUtils/index.ts index 6b031ddb732..beba9b35c28 100644 --- a/src/libs/TransactionUtils/index.ts +++ b/src/libs/TransactionUtils/index.ts @@ -486,10 +486,6 @@ function getUpdatedTransaction({ updatedTransaction.taxCode = transactionChanges.taxCode; } - if (Object.hasOwn(transactionChanges, 'reimbursable') && typeof transactionChanges.reimbursable === 'boolean') { - updatedTransaction.reimbursable = transactionChanges.reimbursable; - } - if (Object.hasOwn(transactionChanges, 'billable') && typeof transactionChanges.billable === 'boolean') { updatedTransaction.billable = transactionChanges.billable; } @@ -530,7 +526,6 @@ function getUpdatedTransaction({ ...(Object.hasOwn(transactionChanges, 'currency') && {currency: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}), ...(Object.hasOwn(transactionChanges, 'merchant') && {merchant: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}), ...(Object.hasOwn(transactionChanges, 'waypoints') && {waypoints: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}), - ...(Object.hasOwn(transactionChanges, 'reimbursable') && {reimbursable: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}), ...(Object.hasOwn(transactionChanges, 'billable') && {billable: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}), ...(Object.hasOwn(transactionChanges, 'category') && {category: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}), ...(Object.hasOwn(transactionChanges, 'tag') && {tag: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}), @@ -689,7 +684,7 @@ function getFormattedAttendees(modifiedAttendees?: Attendee[], attendees?: Atten /** * Return the reimbursable value. Defaults to true to match BE logic. */ -function getReimbursable(transaction: OnyxInputOrEntry): boolean { +function getReimbursable(transaction: Transaction): boolean { return transaction?.reimbursable ?? true; } diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 103a4985887..cae894bc795 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -234,7 +234,6 @@ type BaseTransactionParams = { taxCode?: string; taxAmount?: number; billable?: boolean; - reimbursable?: boolean; customUnitRateID?: string; }; @@ -252,7 +251,6 @@ type MoneyRequestInformation = { createdReportActionIDForThread: string | undefined; onyxData: OnyxData; billable?: boolean; - reimbursable?: boolean; }; type TrackExpenseInformation = { @@ -406,6 +404,7 @@ type RequestMoneyInformation = { policyParams?: BasePolicyParams; gpsPoints?: GPSPoint; action?: IOUAction; + reimbursible?: boolean; transactionParams: RequestMoneyTransactionParams; isRetry?: boolean; shouldPlaySound?: boolean; @@ -608,7 +607,6 @@ type StartSplitBilActionParams = { receipt: Receipt; existingSplitChatReportID?: string; billable?: boolean; - reimbursable?: boolean; category: string | undefined; tag: string | undefined; currency: string; @@ -1021,10 +1019,6 @@ function setMoneyRequestBillable(transactionID: string, billable: boolean) { Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {billable}); } -function setMoneyRequestReimbursable(transactionID: string, reimbursable: boolean) { - Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, {reimbursable}); -} - function setMoneyRequestParticipants(transactionID: string, participants: Participant[] = [], isTestTransaction = false) { // We should change the reportID and isFromGlobalCreate of the test transaction since this flow can start inside an existing report return Onyx.merge(`${ONYXKEYS.COLLECTION.TRANSACTION_DRAFT}${transactionID}`, { @@ -3351,7 +3345,7 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI const {parentChatReport, transactionParams, participantParams, policyParams = {}, moneyRequestReportID = ''} = perDiemExpenseInformation; const {payeeAccountID = userAccountID, payeeEmail = currentUserEmail, participant} = participantParams; const {policy, policyCategories, policyTagList} = policyParams; - const {comment = '', currency, created, category, tag, customUnit, billable, attendees, reimbursable} = transactionParams; + const {comment = '', currency, created, category, tag, customUnit, billable, attendees} = transactionParams; const amount = computePerDiemExpenseAmount(customUnit); const merchant = computePerDiemExpenseMerchant(customUnit, policy); @@ -3429,7 +3423,6 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI tag, customUnit, billable, - reimbursable, pendingFields: {subRates: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}, attendees, }, @@ -3547,7 +3540,6 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI failureData, }, billable, - reimbursable, }; } @@ -4400,24 +4392,6 @@ function updateMoneyRequestBillable( API.write(WRITE_COMMANDS.UPDATE_MONEY_REQUEST_BILLABLE, params, onyxData); } -function updateMoneyRequestReimbursable( - transactionID: string | undefined, - transactionThreadReportID: string | undefined, - value: boolean, - policy: OnyxEntry, - policyTagList: OnyxEntry, - policyCategories: OnyxEntry, -) { - if (!transactionID || !transactionThreadReportID) { - return; - } - const transactionChanges: TransactionChanges = { - reimbursable: value, - }; - const {params, onyxData} = getUpdateMoneyRequestParams(transactionID, transactionThreadReportID, transactionChanges, policy, policyTagList, policyCategories); - API.write(WRITE_COMMANDS.UPDATE_MONEY_REQUEST_REIMBURSABLE, params, onyxData); -} - /** Updates the merchant field of an expense */ function updateMoneyRequestMerchant( transactionID: string, @@ -4743,7 +4717,6 @@ type ConvertTrackedWorkspaceParams = { receipt: Receipt | undefined; waypoints?: string; customUnitRateID?: string; - reimbursable?: boolean; }; type AddTrackedExpenseToPolicyParam = { @@ -5029,7 +5002,18 @@ function shareTrackedExpense(trackedExpenseParams: TrackedExpenseParams) { * Submit expense to another user */ function requestMoney(requestMoneyInformation: RequestMoneyInformation) { - const {report, participantParams, policyParams = {}, transactionParams, gpsPoints, action, shouldHandleNavigation = true, backToReport, shouldPlaySound = true} = requestMoneyInformation; + const { + report, + participantParams, + policyParams = {}, + transactionParams, + gpsPoints, + action, + reimbursible, + shouldHandleNavigation = true, + backToReport, + shouldPlaySound = true, + } = requestMoneyInformation; const {payeeAccountID} = participantParams; const parsedComment = getParsedComment(transactionParams.comment ?? ''); transactionParams.comment = parsedComment; @@ -5044,7 +5028,6 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation) { taxCode = '', taxAmount = 0, billable, - reimbursable, created, attendees, actionableWhisperReportActionID, @@ -5128,7 +5111,6 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation) { policyID: chatReport.policyID, waypoints: sanitizedWaypoints, customUnitRateID, - reimbursable, } : undefined; convertTrackedExpenseToRequest({ @@ -5191,7 +5173,7 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation) { receiptGpsPoints: gpsPoints ? JSON.stringify(gpsPoints) : undefined, transactionThreadReportID, createdReportActionIDForThread, - reimbursable, + reimbursible, description: parsedComment, attendees: attendees ? JSON.stringify(attendees) : undefined, }; @@ -5253,7 +5235,6 @@ function submitPerDiemExpense(submitPerDiemExpenseInformation: PerDiemExpenseInf createdReportActionIDForThread, onyxData, billable, - reimbursable, } = getPerDiemExpenseInformation({ parentChatReport: currentChatReport, participantParams, @@ -5285,7 +5266,6 @@ function submitPerDiemExpense(submitPerDiemExpenseInformation: PerDiemExpenseInf transactionThreadReportID, createdReportActionIDForThread, billable, - reimbursable, attendees: attendees ? JSON.stringify(attendees) : undefined, }; @@ -6168,7 +6148,6 @@ type SplitBillActionsParams = { category?: string; tag?: string; billable?: boolean; - reimbursable?: boolean; iouRequestType?: IOURequestType; existingSplitChatReportID?: string; splitShares?: SplitShares; @@ -6194,7 +6173,6 @@ function splitBill({ category = '', tag = '', billable = false, - reimbursable = false, iouRequestType = CONST.IOU.REQUEST_TYPE.MANUAL, existingSplitChatReportID, splitShares = {}, @@ -6218,7 +6196,6 @@ function splitBill({ tag, splitShares, billable, - reimbursable, iouRequestType, taxCode, taxAmount, @@ -6236,7 +6213,6 @@ function splitBill({ created, tag, billable, - reimbursable, transactionID: splitData.transactionID, reportActionID: splitData.reportActionID, createdReportActionID: splitData.createdReportActionID, @@ -6272,7 +6248,6 @@ function splitBillAndOpenReport({ category = '', tag = '', billable = false, - reimbursable = false, iouRequestType = CONST.IOU.REQUEST_TYPE.MANUAL, splitShares = {}, splitPayerAccountIDs = [], @@ -6296,7 +6271,6 @@ function splitBillAndOpenReport({ tag, splitShares, billable, - reimbursable, iouRequestType, taxCode, taxAmount, @@ -6314,7 +6288,6 @@ function splitBillAndOpenReport({ category, tag, billable, - reimbursable, transactionID: splitData.transactionID, reportActionID: splitData.reportActionID, createdReportActionID: splitData.createdReportActionID, @@ -6347,7 +6320,6 @@ function startSplitBill({ receipt, existingSplitChatReportID, billable = false, - reimbursable = false, category = '', tag = '', currency, @@ -6378,7 +6350,6 @@ function startSplitBill({ taxCode, taxAmount, billable, - reimbursable, filename, }, }); @@ -6514,7 +6485,6 @@ function startSplitBill({ receipt: receiptObject, existingSplitChatReportID, billable, - reimbursable, category, tag, currency, @@ -6664,7 +6634,6 @@ function startSplitBill({ currency, isFromGroupDM: !existingSplitChatReport, billable, - reimbursable, ...(existingSplitChatReport ? {} : {createdReportActionID: splitChatCreatedReportAction.reportActionID}), chatType: splitChatReport?.chatType, taxCode, @@ -6983,23 +6952,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest const {policy, policyCategories, policyTagList} = policyParams; const parsedComment = getParsedComment(transactionParams.comment); transactionParams.comment = parsedComment; - const { - amount, - comment, - currency, - created, - category, - tag, - taxAmount, - taxCode, - merchant, - billable, - reimbursable, - validWaypoints, - customUnitRateID = '', - splitShares = {}, - attendees, - } = transactionParams; + const {amount, comment, currency, created, category, tag, taxAmount, taxCode, merchant, billable, validWaypoints, customUnitRateID = '', splitShares = {}, attendees} = transactionParams; // If the report is an iou or expense report, we should get the linked chat report to be passed to the getMoneyRequestInformation function const isMoneyRequestReport = isMoneyRequestReportReportUtils(report); @@ -7058,7 +7011,6 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest taxCode, taxAmount, billable, - reimbursable, splits: JSON.stringify(splits), chatType: splitData.chatType, description: parsedComment, @@ -7104,7 +7056,6 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest taxCode, taxAmount, billable, - reimbursable, attendees, }, }); @@ -7127,7 +7078,6 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest taxCode, taxAmount, billable, - reimbursable, transactionThreadReportID, createdReportActionIDForThread, payerEmail, @@ -11103,7 +11053,6 @@ export { unholdRequest, updateMoneyRequestAttendees, updateMoneyRequestAmountAndCurrency, - updateMoneyRequestReimbursable, updateMoneyRequestBillable, updateMoneyRequestCategory, updateMoneyRequestDate, @@ -11123,6 +11072,5 @@ export { canSubmitReport, submitPerDiemExpense, calculateDiffAmount, - setMoneyRequestReimbursable, }; export type {GPSPoint as GpsPoint, IOURequestType, StartSplitBilActionParams, CreateTrackExpenseParams, RequestMoneyInformation, ReplaceReceipt}; diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index c957262d6d4..49f611513c6 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -1760,8 +1760,7 @@ function createDraftInitialWorkspace(policyOwnerEmail = '', policyName = '', pol }, areWorkflowsEnabled: shouldEnableWorkflowsByDefault, defaultBillable: false, - defaultReimbursable: true, - disabledFields: {defaultBillable: true, reimbursable: false}, + disabledFields: {defaultBillable: true}, requiresCategory: true, }, }, @@ -1869,8 +1868,7 @@ function buildPolicyData( areReportFieldsEnabled: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, }, defaultBillable: false, - defaultReimbursable: true, - disabledFields: {defaultBillable: true, reimbursable: false}, + disabledFields: {defaultBillable: true}, avatarURL: file?.uri, originalFileName: file?.name, ...optimisticMccGroupData.optimisticData, diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index a861657a0f5..1e97121a09b 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -47,7 +47,6 @@ import { setMoneyRequestBillable, setMoneyRequestCategory, setMoneyRequestReceipt, - setMoneyRequestReimbursable, splitBill, splitBillAndOpenReport, startMoneyRequest, @@ -237,13 +236,6 @@ function IOURequestStepConfirmation({ }); }, [transactionIDs, defaultBillable]); - const defaultReimbursable = !!policy?.defaultReimbursable; - useEffect(() => { - transactionIDs.forEach((transactionID) => { - setMoneyRequestReimbursable(transactionID, defaultReimbursable); - }); - }, [transactionIDs, defaultReimbursable]); - useEffect(() => { // Exit early if the transaction is still loading if (isLoadingTransaction) { @@ -486,7 +478,6 @@ function IOURequestStepConfirmation({ taxCode: transactionTaxCode, taxAmount: transactionTaxAmount, billable: item.billable, - reimbursable: item.reimbursable, actionableWhisperReportActionID: item.actionableWhisperReportActionID, linkedTrackedExpenseReportAction: item.linkedTrackedExpenseReportAction, linkedTrackedExpenseReportID: item.linkedTrackedExpenseReportID, @@ -545,7 +536,6 @@ function IOURequestStepConfirmation({ tag: transaction.tag, customUnit: transaction.comment?.customUnit, billable: transaction.billable, - reimbursable: transaction.reimbursable, attendees: transaction.comment?.attendees, }, }); @@ -652,7 +642,6 @@ function IOURequestStepConfirmation({ splitShares: transaction.splitShares, validWaypoints: getValidWaypoints(transaction.comment?.waypoints, true), billable: transaction.billable, - reimbursable: transaction.reimbursable, attendees: transaction.comment?.attendees, }, backToReport, @@ -717,7 +706,6 @@ function IOURequestStepConfirmation({ receipt: currentTransactionReceiptFile, existingSplitChatReportID: report?.reportID, billable: transaction.billable, - reimbursable: transaction.reimbursable, category: transaction.category, tag: transaction.tag, currency: transaction.currency, @@ -745,7 +733,6 @@ function IOURequestStepConfirmation({ tag: transaction.tag, existingSplitChatReportID: report?.reportID, billable: transaction.billable, - reimbursable: transaction.reimbursable, iouRequestType: transaction.iouRequestType, splitShares: transaction.splitShares, splitPayerAccountIDs: transaction.splitPayerAccountIDs ?? [], @@ -771,7 +758,6 @@ function IOURequestStepConfirmation({ category: transaction.category, tag: transaction.tag, billable: !!transaction.billable, - reimbursable: !!transaction.reimbursable, iouRequestType: transaction.iouRequestType, splitShares: transaction.splitShares, splitPayerAccountIDs: transaction.splitPayerAccountIDs, @@ -935,13 +921,6 @@ function IOURequestStepConfirmation({ [currentTransactionID], ); - const setReimbursable = useCallback( - (reimbursable: boolean) => { - setMoneyRequestReimbursable(currentTransactionID, reimbursable); - }, - [currentTransactionID], - ); - // This loading indicator is shown because the transaction originalCurrency is being updated later than the component mounts. // To prevent the component from rendering with the wrong currency, we show a loading indicator until the correct currency is set. const isLoading = !!transaction?.originalCurrency; @@ -1104,8 +1083,6 @@ function IOURequestStepConfirmation({ payeePersonalDetails={payeePersonalDetails} isConfirmed={isConfirmed} isConfirming={isConfirming} - iouIsReimbursable={transaction?.reimbursable} - onToggleReimbursable={setReimbursable} isReceiptEditable /> diff --git a/src/pages/iou/request/step/IOURequestStepDistance.tsx b/src/pages/iou/request/step/IOURequestStepDistance.tsx index fc5b4d575c9..88623eb2d46 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -350,7 +350,6 @@ function IOURequestStepDistance({ currency: transaction?.currency ?? 'USD', merchant: translate('iou.fieldPending'), billable: !!policy?.defaultBillable, - reimbursable: !!policy?.defaultReimbursable, validWaypoints: getValidWaypoints(waypoints, true), customUnitRateID: DistanceRequestUtils.getCustomUnitRateID(report.reportID), splitShares: transaction?.splitShares, diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 08d5877c86e..eadece5d418 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -1740,9 +1740,6 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< /** Whether transactions should be billable by default */ defaultBillable?: boolean; - /** Whether transactions should be reimbursable by default */ - defaultReimbursable?: boolean; - /** The workspace description */ description?: string;