From d1e63ea8d43618f3c58b17d8b00d8407bc32ce8a Mon Sep 17 00:00:00 2001 From: daledah Date: Thu, 27 Mar 2025 16:35:54 +0700 Subject: [PATCH 01/10] feat: add reimbursable toggle to create expense flow --- .../MoneyRequestConfirmationList.tsx | 10 +++++++ .../MoneyRequestConfirmationListFooter.tsx | 29 +++++++++++++++++++ src/libs/API/parameters/RequestMoneyParams.ts | 2 +- src/libs/actions/IOU.ts | 13 +++++++-- .../step/IOURequestStepConfirmation.tsx | 11 +++++++ src/types/onyx/Policy.ts | 3 ++ 6 files changed, 64 insertions(+), 4 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 65353279d3ff..691360d09b26 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -180,6 +180,12 @@ 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; @@ -220,6 +226,8 @@ function MoneyRequestConfirmationList({ isConfirming, onPDFLoadError, onPDFPassword, + iouIsReimbursable = true, + onToggleReimbursable, }: MoneyRequestConfirmationListProps) { const [policyCategoriesReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`); const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`); @@ -1077,6 +1085,8 @@ function MoneyRequestConfirmationList({ unit={unit} onPDFLoadError={onPDFLoadError} onPDFPassword={onPDFPassword} + iouIsReimbursable={iouIsReimbursable} + onToggleReimbursable={onToggleReimbursable} /> ); diff --git a/src/components/MoneyRequestConfirmationListFooter.tsx b/src/components/MoneyRequestConfirmationListFooter.tsx index bee481ca18e3..b7118b709a10 100644 --- a/src/components/MoneyRequestConfirmationListFooter.tsx +++ b/src/components/MoneyRequestConfirmationListFooter.tsx @@ -24,6 +24,7 @@ import { getTaxAmount, getTaxName, isAmountMissing, + isCardTransaction, isCreatedMissing, isFetchingWaypointsFromServer, shouldShowAttendees as shouldShowAttendeesTransactionUtils, @@ -192,6 +193,12 @@ 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({ @@ -242,6 +249,8 @@ function MoneyRequestConfirmationListFooter({ unit, onPDFLoadError, onPDFPassword, + iouIsReimbursable, + onToggleReimbursable, }: MoneyRequestConfirmationListFooterProps) { const styles = useThemeStyles(); const {translate, toLocaleDigit} = useLocalize(); @@ -282,6 +291,7 @@ 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 @@ -605,6 +615,25 @@ function MoneyRequestConfirmationListFooter({ shouldShow: shouldShowAttendees, isSupplementary: true, }, + { + item: ( + + onToggleReimbursable?.(isOn)} + isActive={iouIsReimbursable} + disabled={isReadOnly} + wrapperStyle={styles.flex1} + /> + + ), + shouldShow: shouldShowReimbursable, + isSupplementary: true, + }, { item: ( { + setMoneyRequestReimbursable(transactionID, reimbursable); + }, + [transactionID], + ); + // 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; @@ -953,6 +962,8 @@ function IOURequestStepConfirmation({ shouldPlaySound={iouType === CONST.IOU.TYPE.PAY} isConfirmed={isConfirmed} isConfirming={isConfirming} + iouIsReimbursable={transaction?.reimbursable ?? policy?.defaultReimbursable} + onToggleReimbursable={setReimbursable} /> diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 6a62ee83ff68..0b96b5d7f68d 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -1835,6 +1835,9 @@ 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; From 47d13ec1c1b1a3bb604ed0564f4dd8265685c0fb Mon Sep 17 00:00:00 2001 From: daledah Date: Thu, 27 Mar 2025 16:55:33 +0700 Subject: [PATCH 02/10] fix: prettier --- src/libs/actions/IOU.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 8f181b86bfe6..38e59a78839a 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -4835,7 +4835,7 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation) { policyID: chatReport.policyID, waypoints: sanitizedWaypoints, customUnitRateID, - reimbursable + reimbursable, } : undefined; convertTrackedExpenseToRequest({ From 110ad5152e538e08edad91a06a5574de29fa0a38 Mon Sep 17 00:00:00 2001 From: daledah Date: Fri, 18 Apr 2025 01:21:19 +0700 Subject: [PATCH 03/10] feat: implement Reimbursable button in money request view --- src/CONST.ts | 1 + .../ReportActionItem/MoneyRequestView.tsx | 32 ++++++++++++++++++- src/libs/API/types.ts | 1 + src/libs/ModifiedExpenseMessage.ts | 11 ++----- src/libs/ReportUtils.ts | 9 ++++++ src/libs/TransactionUtils/index.ts | 7 +++- src/libs/actions/IOU.ts | 19 +++++++++++ 7 files changed, 69 insertions(+), 11 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 14adbe9e7b7d..7a1b4c8d41bc 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -3650,6 +3650,7 @@ const CONST = { TAG: 'tag', TAX_RATE: 'taxRate', TAX_AMOUNT: 'taxAmount', + REIMBURSABLE: 'reimbursable', }, FOOTER: { EXPENSE_MANAGEMENT_URL: `${USE_EXPENSIFY_URL}/expense-management`, diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index c75a74f5eea6..2e09c771938e 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -1,3 +1,4 @@ +import {Str} from 'expensify-common'; import mapValues from 'lodash/mapValues'; import React, {useCallback, useMemo, useState} from 'react'; import {View} from 'react-native'; @@ -50,6 +51,7 @@ import { getCardName, getDescription, getDistanceInMeters, + getReimbursable, getTagForDisplay, getTaxName, hasMissingSmartscanFields, @@ -65,7 +67,7 @@ import { import ViolationsUtils from '@libs/Violations/ViolationsUtils'; import Navigation from '@navigation/Navigation'; import AnimatedEmptyStateBackground from '@pages/home/report/AnimatedEmptyStateBackground'; -import {cleanUpMoneyRequest, updateMoneyRequestBillable} from '@userActions/IOU'; +import {cleanUpMoneyRequest, updateMoneyRequestBillable, updateMoneyRequestReimbursable} from '@userActions/IOU'; import {navigateToConciergeChatAndDeleteReport} from '@userActions/Report'; import {clearAllRelatedReportActionErrors} from '@userActions/ReportActions'; import {clearError, getLastModifiedExpense, revert} from '@userActions/Transaction'; @@ -151,6 +153,7 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals currency: transactionCurrency, comment: transactionDescription, merchant: transactionMerchant, + reimbursable: transactionReimbursable, billable: transactionBillable, category: transactionCategory, tag: transactionTag, @@ -215,6 +218,9 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing const shouldShowTag = isPolicyExpenseChat && (transactionTag || hasEnabledTags(policyTagLists)); const shouldShowBillable = isPolicyExpenseChat && (!!transactionBillable || !(policy?.disabledFields?.defaultBillable ?? true) || !!updatedTransaction?.billable); + const shouldShowReimbursable = + isPolicyExpenseChat && (!!transactionBillable || !(policy?.disabledFields?.reimbursable ?? true) || !!updatedTransaction?.reimbursable) && !isCardTransaction; + const canEditReimbursable = canUserPerformWriteAction && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.REIMBURSABLE); const shouldShowAttendees = useMemo(() => shouldShowAttendeesTransactionUtils(iouType, policy), [iouType, policy]); const shouldShowTax = isTaxTrackingEnabled(isPolicyExpenseChat, policy, isDistanceRequest, isPerDiemRequest); @@ -264,6 +270,17 @@ 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}`; @@ -776,6 +793,19 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals /> )} + {shouldShowReimbursable && ( + + + {Str.UCFirst(translate('iou.reimbursable'))} + + + + )} {shouldShowBillable && ( diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 7aabb68d618d..226085234473 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -186,6 +186,7 @@ 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', diff --git a/src/libs/ModifiedExpenseMessage.ts b/src/libs/ModifiedExpenseMessage.ts index c4a9028118dc..0f438053f807 100644 --- a/src/libs/ModifiedExpenseMessage.ts +++ b/src/libs/ModifiedExpenseMessage.ts @@ -36,13 +36,6 @@ 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. */ @@ -334,8 +327,8 @@ function getForReportAction({ const hasModifiedReimbursable = isReportActionOriginalMessageAnObject && 'oldReimbursable' in reportActionOriginalMessage && 'reimbursable' in reportActionOriginalMessage; if (hasModifiedReimbursable) { buildMessageFragmentForValue( - getBooleanLiteralMessage(reportActionOriginalMessage?.reimbursable, translateLocal('iou.reimbursable'), translateLocal('iou.nonReimbursable')), - getBooleanLiteralMessage(reportActionOriginalMessage?.oldReimbursable, translateLocal('iou.reimbursable'), translateLocal('iou.nonReimbursable')), + reportActionOriginalMessage?.reimbursable ?? '', + reportActionOriginalMessage?.oldReimbursable ?? '', translateLocal('iou.expense'), true, setFragments, diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 29c59b8dde5e..deca509ba4f8 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -641,6 +641,7 @@ type TransactionDetails = { customUnitRateID?: string; comment: string; category: string; + reimbursable: boolean; billable: boolean; tag: string; mccGroup?: ValueOf; @@ -3673,6 +3674,7 @@ function getTransactionDetails(transaction: OnyxInputOrEntry, creat waypoints: getWaypoints(transaction), customUnitRateID: getRateID(transaction), category: getCategory(transaction), + reimbursable: getReimbursable(transaction), billable: getBillable(transaction), tag: getTag(transaction), mccGroup: getMCCGroup(transaction), @@ -3775,6 +3777,7 @@ 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, ]; if (!isMoneyRequestAction(reportAction) || !canEditMoneyRequest(reportAction)) { @@ -4312,6 +4315,12 @@ 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 ef568db066a2..2905b9e90f39 100644 --- a/src/libs/TransactionUtils/index.ts +++ b/src/libs/TransactionUtils/index.ts @@ -475,6 +475,10 @@ 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; } @@ -515,6 +519,7 @@ 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}), @@ -673,7 +678,7 @@ function getFormattedAttendees(modifiedAttendees?: Attendee[], attendees?: Atten /** * Return the reimbursable value. Defaults to true to match BE logic. */ -function getReimbursable(transaction: Transaction): boolean { +function getReimbursable(transaction: OnyxInputOrEntry): boolean { return transaction?.reimbursable ?? true; } diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 45b3250fa6bd..7c4100194015 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -4264,6 +4264,24 @@ 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, @@ -10590,6 +10608,7 @@ export { unholdRequest, updateMoneyRequestAttendees, updateMoneyRequestAmountAndCurrency, + updateMoneyRequestReimbursable, updateMoneyRequestBillable, updateMoneyRequestCategory, updateMoneyRequestDate, From 353b28375a7e076d02edca52cae925ccc675ceb5 Mon Sep 17 00:00:00 2001 From: daledah Date: Fri, 18 Apr 2025 01:58:08 +0700 Subject: [PATCH 04/10] fix: lint and typecheck --- src/components/MoneyRequestConfirmationList.tsx | 17 +++++++++-------- src/libs/API/types.ts | 1 + .../request/step/IOURequestStepConfirmation.tsx | 12 ++++++------ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/components/MoneyRequestConfirmationList.tsx b/src/components/MoneyRequestConfirmationList.tsx index 56fc70a03980..35d371b36073 100755 --- a/src/components/MoneyRequestConfirmationList.tsx +++ b/src/components/MoneyRequestConfirmationList.tsx @@ -233,17 +233,18 @@ function MoneyRequestConfirmationList({ iouIsReimbursable = true, onToggleReimbursable, }: MoneyRequestConfirmationListProps) { - const [policyCategoriesReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`); - const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`); - const [policyReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`); - const [policyDraft] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_DRAFTS}${policyID}`); + const [policyCategoriesReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`, {canBeMissing: false}); + const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`, {canBeMissing: false}); + const [policyReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`, {canBeMissing: false}); + const [policyDraft] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_DRAFTS}${policyID}`, {canBeMissing: true}); const [defaultMileageRate] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_DRAFTS}${policyID}`, { selector: (selectedPolicy) => DistanceRequestUtils.getDefaultMileageRate(selectedPolicy), + canBeMissing: true, }); - const [policyCategoriesDraft] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES_DRAFT}${policyID}`); - const [lastSelectedDistanceRates] = useOnyx(ONYXKEYS.NVP_LAST_SELECTED_DISTANCE_RATES); - const [currencyList] = useOnyx(ONYXKEYS.CURRENCY_LIST); - const [betas] = useOnyx(ONYXKEYS.BETAS); + const [policyCategoriesDraft] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES_DRAFT}${policyID}`, {canBeMissing: true}); + const [lastSelectedDistanceRates] = useOnyx(ONYXKEYS.NVP_LAST_SELECTED_DISTANCE_RATES, {canBeMissing: true}); + const [currencyList] = useOnyx(ONYXKEYS.CURRENCY_LIST, {canBeMissing: false}); + const [betas] = useOnyx(ONYXKEYS.BETAS, {canBeMissing: false}); const isTestReceipt = useMemo(() => { return transaction?.receipt?.isTestReceipt ?? false; diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 226085234473..510bbe15174f 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -645,6 +645,7 @@ 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/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 9d500ca01a68..91b81f7b2ace 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -85,12 +85,12 @@ function IOURequestStepConfirmation({ const currentUserPersonalDetails = useCurrentUserPersonalDetails(); const personalDetails = usePersonalDetails(); - const [policyDraft] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_DRAFTS}${getIOURequestPolicyID(transaction, reportDraft)}`); - const [policyReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${getIOURequestPolicyID(transaction, reportReal)}`); - const [policyCategoriesReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${getIOURequestPolicyID(transaction, reportReal)}`); - const [policyCategoriesDraft] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${getIOURequestPolicyID(transaction, reportDraft)}`); - const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${getIOURequestPolicyID(transaction, reportReal)}`); - const [userLocation] = useOnyx(ONYXKEYS.USER_LOCATION); + const [policyDraft] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_DRAFTS}${getIOURequestPolicyID(transaction, reportDraft)}`, {canBeMissing: true}); + const [policyReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${getIOURequestPolicyID(transaction, reportReal)}`, {canBeMissing: false}); + const [policyCategoriesReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${getIOURequestPolicyID(transaction, reportReal)}`, {canBeMissing: false}); + const [policyCategoriesDraft] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${getIOURequestPolicyID(transaction, reportDraft)}`, {canBeMissing: true}); + const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${getIOURequestPolicyID(transaction, reportReal)}`, {canBeMissing: false}); + const [userLocation] = useOnyx(ONYXKEYS.USER_LOCATION, {canBeMissing: true}); /* * We want to use a report from the transaction if it exists From c793448188c11b56e1af16acc606819c622f85a5 Mon Sep 17 00:00:00 2001 From: daledah Date: Fri, 18 Apr 2025 02:07:07 +0700 Subject: [PATCH 05/10] fix: lint --- src/pages/iou/request/step/IOURequestStepConfirmation.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 91b81f7b2ace..f1f1b4b212c5 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -121,7 +121,7 @@ function IOURequestStepConfirmation({ const requestType = getRequestType(transaction); const isDistanceRequest = requestType === CONST.IOU.REQUEST_TYPE.DISTANCE; const isPerDiemRequest = requestType === CONST.IOU.REQUEST_TYPE.PER_DIEM; - const [lastLocationPermissionPrompt] = useOnyx(ONYXKEYS.NVP_LAST_LOCATION_PERMISSION_PROMPT); + const [lastLocationPermissionPrompt] = useOnyx(ONYXKEYS.NVP_LAST_LOCATION_PERMISSION_PROMPT, {canBeMissing: true}); const receiptFilename = transaction?.filename; const receiptPath = transaction?.receipt?.source; From 2a1085cf33a424550a5f9d1fac12032f3e5efc30 Mon Sep 17 00:00:00 2001 From: daledah Date: Mon, 21 Apr 2025 15:39:11 +0700 Subject: [PATCH 06/10] fix: lint --- src/libs/actions/IOU.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 547c6c252df3..3b0b6167a600 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -123,7 +123,6 @@ import { getOutstandingChildRequest, getParsedComment, getPersonalDetailsForAccountID, - getReportNameValuePairs, getReportNotificationPreference, getReportOrDraftReport, getReportTransactions, @@ -731,6 +730,18 @@ Onyx.connect({ callback: (value) => (personalDetailsList = value), }); +let allReportNameValuePairs: OnyxCollection; +Onyx.connect({ + key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, + waitForCollectionCallback: true, + callback: (value) => { + if (!value) { + return; + } + allReportNameValuePairs = value; + }, +}); + /** * @private * After finishing the action in RHP from the Inbox tab, besides dismissing the modal, we should open the report. @@ -8698,7 +8709,7 @@ function canApproveIOU(iouReport: OnyxTypes.OnyxInputOrEntry | const isOpenExpenseReport = isOpenExpenseReportReportUtils(iouReport); const isApproved = isReportApproved({report: iouReport}); const iouSettled = isSettled(iouReport); - const reportNameValuePairs = getReportNameValuePairs(iouReport?.reportID); + const reportNameValuePairs = allReportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT}${iouReport?.reportID}`]; const isArchivedExpenseReport = isArchivedReport(reportNameValuePairs); const reportTransactions = getReportTransactions(iouReport?.reportID); const hasOnlyPendingCardOrScanningTransactions = reportTransactions.length > 0 && reportTransactions.every(isPendingCardOrScanningTransaction); @@ -8733,7 +8744,7 @@ function canIOUBePaid( shouldCheckApprovedState = true, ) { const isPolicyExpenseChat = isPolicyExpenseChatReportUtil(chatReport); - const reportNameValuePairs = chatReportRNVP ?? getReportNameValuePairs(chatReport?.reportID); + const reportNameValuePairs = chatReportRNVP ?? allReportNameValuePairs?.[`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${chatReport?.reportID}`]; const isChatReportArchived = isArchivedReport(reportNameValuePairs); const iouSettled = isSettled(iouReport); From ad174f6703413fa1f2289017ce488e2991c4bab4 Mon Sep 17 00:00:00 2001 From: daledah Date: Sat, 26 Apr 2025 10:19:31 +0700 Subject: [PATCH 07/10] fix: add reimbursable for other transactions --- .../ReportActionItem/MoneyRequestView.tsx | 26 +++++------ .../parameters/CreateDistanceRequestParams.ts | 1 + .../parameters/CreatePerDiemRequestParams.ts | 1 + src/libs/API/parameters/SplitBillParams.ts | 1 + .../API/parameters/StartSplitBillParams.ts | 1 + src/libs/actions/IOU.ts | 44 +++++++++++++++++-- .../step/IOURequestStepConfirmation.tsx | 14 +++++- .../request/step/IOURequestStepDistance.tsx | 1 + 8 files changed, 70 insertions(+), 19 deletions(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index b80ab2115ae6..3286c5f89c4f 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -781,19 +781,6 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals /> )} - {shouldShowReimbursable && ( - - - {Str.UCFirst(translate('iou.reimbursable'))} - - - - )} {!!parentReportID && !!canUseTableReportView && ( )} + {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 915a3e4cc133..3b69f392ca8e 100644 --- a/src/libs/API/parameters/CreateDistanceRequestParams.ts +++ b/src/libs/API/parameters/CreateDistanceRequestParams.ts @@ -15,6 +15,7 @@ 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 b2fe0b541cc5..4f57d6e338fd 100644 --- a/src/libs/API/parameters/CreatePerDiemRequestParams.ts +++ b/src/libs/API/parameters/CreatePerDiemRequestParams.ts @@ -20,6 +20,7 @@ type CreatePerDiemRequestParams = { transactionThreadReportID: string; createdReportActionIDForThread: string | undefined; billable?: boolean; + reimbursable?: boolean; }; export default CreatePerDiemRequestParams; diff --git a/src/libs/API/parameters/SplitBillParams.ts b/src/libs/API/parameters/SplitBillParams.ts index 3fda11b9ca98..bc99bf176e2d 100644 --- a/src/libs/API/parameters/SplitBillParams.ts +++ b/src/libs/API/parameters/SplitBillParams.ts @@ -9,6 +9,7 @@ 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 10f1029a0fba..031d75aca525 100644 --- a/src/libs/API/parameters/StartSplitBillParams.ts +++ b/src/libs/API/parameters/StartSplitBillParams.ts @@ -13,6 +13,7 @@ type StartSplitBillParams = { isFromGroupDM: boolean; createdReportActionID?: string; billable: boolean; + reimbursable: boolean; chatType?: string; taxCode?: string; taxAmount?: number; diff --git a/src/libs/actions/IOU.ts b/src/libs/actions/IOU.ts index 547d964377fb..66c13f89bb1f 100644 --- a/src/libs/actions/IOU.ts +++ b/src/libs/actions/IOU.ts @@ -229,6 +229,7 @@ type BaseTransactionParams = { taxCode?: string; taxAmount?: number; billable?: boolean; + reimbursable?: boolean; customUnitRateID?: string; }; @@ -246,6 +247,7 @@ type MoneyRequestInformation = { createdReportActionIDForThread: string | undefined; onyxData: OnyxData; billable?: boolean; + reimbursable?: boolean; }; type TrackExpenseInformation = { @@ -395,7 +397,6 @@ type RequestMoneyInformation = { policyParams?: BasePolicyParams; gpsPoints?: GPSPoint; action?: IOUAction; - reimbursable?: boolean; transactionParams: RequestMoneyTransactionParams; isRetry?: boolean; }; @@ -583,6 +584,7 @@ type StartSplitBilActionParams = { receipt: Receipt; existingSplitChatReportID?: string; billable?: boolean; + reimbursable?: boolean; category: string | undefined; tag: string | undefined; currency: string; @@ -3274,7 +3276,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} = transactionParams; + const {comment = '', currency, created, category, tag, customUnit, billable, reimbursable} = transactionParams; const amount = computePerDiemExpenseAmount(customUnit); const merchant = computePerDiemExpenseMerchant(customUnit, policy); @@ -3352,6 +3354,7 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI tag, customUnit, billable, + reimbursable, pendingFields: {subRates: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD}, }, }); @@ -3468,6 +3471,7 @@ function getPerDiemExpenseInformation(perDiemExpenseInformation: PerDiemExpenseI failureData, }, billable, + reimbursable, }; } @@ -4900,7 +4904,7 @@ function shareTrackedExpense(trackedExpenseParams: TrackedExpenseParams) { * Submit expense to another user */ function requestMoney(requestMoneyInformation: RequestMoneyInformation) { - const {report, participantParams, policyParams = {}, transactionParams, gpsPoints, action, reimbursable} = requestMoneyInformation; + const {report, participantParams, policyParams = {}, transactionParams, gpsPoints, action} = requestMoneyInformation; const {payeeAccountID} = participantParams; const parsedComment = getParsedComment(transactionParams.comment ?? ''); transactionParams.comment = parsedComment; @@ -4915,6 +4919,7 @@ function requestMoney(requestMoneyInformation: RequestMoneyInformation) { taxCode = '', taxAmount = 0, billable, + reimbursable, created, attendees, actionableWhisperReportActionID, @@ -5117,6 +5122,7 @@ function submitPerDiemExpense(submitPerDiemExpenseInformation: PerDiemExpenseInf createdReportActionIDForThread, onyxData, billable, + reimbursable, } = getPerDiemExpenseInformation({ parentChatReport: currentChatReport, participantParams, @@ -5148,6 +5154,7 @@ function submitPerDiemExpense(submitPerDiemExpenseInformation: PerDiemExpenseInf transactionThreadReportID, createdReportActionIDForThread, billable, + reimbursable, }; API.write(WRITE_COMMANDS.CREATE_PER_DIEM_REQUEST, parameters, onyxData); @@ -6010,6 +6017,7 @@ type SplitBillActionsParams = { category?: string; tag?: string; billable?: boolean; + reimbursable?: boolean; iouRequestType?: IOURequestType; existingSplitChatReportID?: string; splitShares?: SplitShares; @@ -6035,6 +6043,7 @@ function splitBill({ category = '', tag = '', billable = false, + reimbursable = false, iouRequestType = CONST.IOU.REQUEST_TYPE.MANUAL, existingSplitChatReportID, splitShares = {}, @@ -6058,6 +6067,7 @@ function splitBill({ tag, splitShares, billable, + reimbursable, iouRequestType, taxCode, taxAmount, @@ -6075,6 +6085,7 @@ function splitBill({ created, tag, billable, + reimbursable, transactionID: splitData.transactionID, reportActionID: splitData.reportActionID, createdReportActionID: splitData.createdReportActionID, @@ -6109,6 +6120,7 @@ function splitBillAndOpenReport({ category = '', tag = '', billable = false, + reimbursable = false, iouRequestType = CONST.IOU.REQUEST_TYPE.MANUAL, splitShares = {}, splitPayerAccountIDs = [], @@ -6132,6 +6144,7 @@ function splitBillAndOpenReport({ tag, splitShares, billable, + reimbursable, iouRequestType, taxCode, taxAmount, @@ -6149,6 +6162,7 @@ function splitBillAndOpenReport({ category, tag, billable, + reimbursable, transactionID: splitData.transactionID, reportActionID: splitData.reportActionID, createdReportActionID: splitData.createdReportActionID, @@ -6180,6 +6194,7 @@ function startSplitBill({ receipt, existingSplitChatReportID, billable = false, + reimbursable = false, category = '', tag = '', currency, @@ -6209,6 +6224,7 @@ function startSplitBill({ taxCode, taxAmount, billable, + reimbursable, filename, }, }); @@ -6344,6 +6360,7 @@ function startSplitBill({ receipt: receiptObject, existingSplitChatReportID, billable, + reimbursable, category, tag, currency, @@ -6493,6 +6510,7 @@ function startSplitBill({ currency, isFromGroupDM: !existingSplitChatReport, billable, + reimbursable, ...(existingSplitChatReport ? {} : {createdReportActionID: splitChatCreatedReportAction.reportActionID}), chatType: splitChatReport?.chatType, taxCode, @@ -6806,7 +6824,22 @@ 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, validWaypoints, customUnitRateID = '', splitShares = {}} = transactionParams; + const { + amount, + comment, + currency, + created, + category, + tag, + taxAmount, + taxCode, + merchant, + billable, + reimbursable, + validWaypoints, + customUnitRateID = '', + splitShares = {}, + } = 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); @@ -6864,6 +6897,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest taxCode, taxAmount, billable, + reimbursable, splits: JSON.stringify(splits), chatType: splitData.chatType, description: parsedComment, @@ -6908,6 +6942,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest taxCode, taxAmount, billable, + reimbursable, }, }); @@ -6929,6 +6964,7 @@ function createDistanceRequest(distanceRequestInformation: CreateDistanceRequest taxCode, taxAmount, billable, + reimbursable, transactionThreadReportID, createdReportActionIDForThread, payerEmail, diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 48c4394a1cdf..58de2648282b 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -212,6 +212,11 @@ function IOURequestStepConfirmation({ setMoneyRequestBillable(transactionID, defaultBillable); }, [transactionID, defaultBillable]); + const defaultReimbursable = !!policy?.defaultReimbursable; + useEffect(() => { + setMoneyRequestReimbursable(transactionID, defaultReimbursable); + }, [transactionID, defaultReimbursable]); + useEffect(() => { // Exit early if the transaction is still loading if (isLoadingTransaction) { @@ -405,7 +410,6 @@ function IOURequestStepConfirmation({ }, gpsPoints, action, - reimbursable: transaction.reimbursable ?? policy?.defaultReimbursable, transactionParams: { amount: isTestReceipt ? CONST.TEST_RECEIPT.AMOUNT : transaction.amount, attendees: transaction.comment?.attendees, @@ -419,6 +423,7 @@ function IOURequestStepConfirmation({ taxCode: transactionTaxCode, taxAmount: transactionTaxAmount, billable: transaction.billable, + reimbursable: transaction.reimbursable, actionableWhisperReportActionID: transaction.actionableWhisperReportActionID, linkedTrackedExpenseReportAction: transaction.linkedTrackedExpenseReportAction, linkedTrackedExpenseReportID: transaction.linkedTrackedExpenseReportID, @@ -472,6 +477,7 @@ function IOURequestStepConfirmation({ tag: transaction.tag, customUnit: transaction.comment?.customUnit, billable: transaction.billable, + reimbursable: transaction.reimbursable, }, }); }, @@ -569,6 +575,7 @@ function IOURequestStepConfirmation({ splitShares: transaction.splitShares, validWaypoints: getValidWaypoints(transaction.comment?.waypoints, true), billable: transaction.billable, + reimbursable: transaction.reimbursable, }, }); }, @@ -617,6 +624,7 @@ function IOURequestStepConfirmation({ receipt: receiptFile, existingSplitChatReportID: report?.reportID, billable: transaction.billable, + reimbursable: transaction.reimbursable, category: transaction.category, tag: transaction.tag, currency: transaction.currency, @@ -644,6 +652,7 @@ function IOURequestStepConfirmation({ tag: transaction.tag, existingSplitChatReportID: report?.reportID, billable: transaction.billable, + reimbursable: transaction.reimbursable, iouRequestType: transaction.iouRequestType, splitShares: transaction.splitShares, splitPayerAccountIDs: transaction.splitPayerAccountIDs ?? [], @@ -669,6 +678,7 @@ function IOURequestStepConfirmation({ category: transaction.category, tag: transaction.tag, billable: !!transaction.billable, + reimbursable: !!transaction.reimbursable, iouRequestType: transaction.iouRequestType, splitShares: transaction.splitShares, splitPayerAccountIDs: transaction.splitPayerAccountIDs, @@ -984,7 +994,7 @@ function IOURequestStepConfirmation({ shouldPlaySound={iouType === CONST.IOU.TYPE.PAY} isConfirmed={isConfirmed} isConfirming={isConfirming} - iouIsReimbursable={transaction?.reimbursable ?? policy?.defaultReimbursable} + 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 84dfbd79d56d..91094dc546c9 100644 --- a/src/pages/iou/request/step/IOURequestStepDistance.tsx +++ b/src/pages/iou/request/step/IOURequestStepDistance.tsx @@ -365,6 +365,7 @@ function IOURequestStepDistance({ currency: transaction?.currency ?? 'USD', merchant: translate('iou.fieldPending'), billable: !!policy?.defaultBillable, + reimbursable: transaction?.reimbursable ?? policy?.defaultReimbursable ?? true, validWaypoints: getValidWaypoints(waypoints, true), customUnitRateID: DistanceRequestUtils.getCustomUnitRateID(report.reportID), splitShares: transaction?.splitShares, From 7484fe7150def2c5e6a253b60b2a70b39d8a27a6 Mon Sep 17 00:00:00 2001 From: daledah Date: Sat, 26 Apr 2025 10:25:01 +0700 Subject: [PATCH 08/10] fix: correct reimbursable logics --- src/components/ReportActionItem/MoneyRequestView.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/ReportActionItem/MoneyRequestView.tsx b/src/components/ReportActionItem/MoneyRequestView.tsx index 3286c5f89c4f..fc4aa3954b9c 100644 --- a/src/components/ReportActionItem/MoneyRequestView.tsx +++ b/src/components/ReportActionItem/MoneyRequestView.tsx @@ -221,7 +221,7 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals const shouldShowTag = isPolicyExpenseChat && (transactionTag || hasEnabledTags(policyTagLists)); const shouldShowBillable = isPolicyExpenseChat && (!!transactionBillable || !(policy?.disabledFields?.defaultBillable ?? true) || !!updatedTransaction?.billable); const shouldShowReimbursable = - isPolicyExpenseChat && (!!transactionBillable || !(policy?.disabledFields?.reimbursable ?? true) || !!updatedTransaction?.reimbursable) && !isCardTransaction; + isPolicyExpenseChat && (!!transactionReimbursable || !(policy?.disabledFields?.reimbursable ?? true) || !!updatedTransaction?.reimbursable) && !isCardTransaction; const canEditReimbursable = canUserPerformWriteAction && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.REIMBURSABLE); const shouldShowAttendees = useMemo(() => shouldShowAttendeesTransactionUtils(iouType, policy), [iouType, policy]); From 681a15d4bf4ada8917e11f7f7e820a29a0a58970 Mon Sep 17 00:00:00 2001 From: daledah Date: Wed, 30 Apr 2025 17:37:58 +0700 Subject: [PATCH 09/10] fix: create policy with defailtReimbursable --- src/libs/actions/Policy/Policy.ts | 6 ++++-- src/pages/iou/request/step/IOURequestStepConfirmation.tsx | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/Policy/Policy.ts b/src/libs/actions/Policy/Policy.ts index 275d5e92403c..c0509f1ba65e 100644 --- a/src/libs/actions/Policy/Policy.ts +++ b/src/libs/actions/Policy/Policy.ts @@ -1759,7 +1759,8 @@ function createDraftInitialWorkspace(policyOwnerEmail = '', policyName = '', pol }, areWorkflowsEnabled: shouldEnableWorkflowsByDefault, defaultBillable: false, - disabledFields: {defaultBillable: true}, + defaultReimbursable: true, + disabledFields: {defaultBillable: true, reimbursable: false}, requiresCategory: true, }, }, @@ -1866,7 +1867,8 @@ function buildPolicyData( type: CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD, }, defaultBillable: false, - disabledFields: {defaultBillable: true}, + defaultReimbursable: true, + disabledFields: {defaultBillable: true, reimbursable: false}, 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 58de2648282b..915e1f9b2294 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -216,6 +216,7 @@ function IOURequestStepConfirmation({ useEffect(() => { setMoneyRequestReimbursable(transactionID, defaultReimbursable); }, [transactionID, defaultReimbursable]); + console.log(policy, defaultReimbursable, transaction?.reimbursable); useEffect(() => { // Exit early if the transaction is still loading From e2e3b573ae62dc88ed71fa4ee948003687996bd0 Mon Sep 17 00:00:00 2001 From: daledah Date: Wed, 30 Apr 2025 17:39:37 +0700 Subject: [PATCH 10/10] fix: remove unused code --- src/pages/iou/request/step/IOURequestStepConfirmation.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx index 915e1f9b2294..58de2648282b 100644 --- a/src/pages/iou/request/step/IOURequestStepConfirmation.tsx +++ b/src/pages/iou/request/step/IOURequestStepConfirmation.tsx @@ -216,7 +216,6 @@ function IOURequestStepConfirmation({ useEffect(() => { setMoneyRequestReimbursable(transactionID, defaultReimbursable); }, [transactionID, defaultReimbursable]); - console.log(policy, defaultReimbursable, transaction?.reimbursable); useEffect(() => { // Exit early if the transaction is still loading