Skip to content

Commit 9f214aa

Browse files
arosiclairOSBotify
authored andcommitted
Merge pull request #62524 from daledah/revert/58588
revert: add reimbursable toggle to create expense flow (cherry picked from commit 3f70097) (cherry-picked to staging by arosiclair)
1 parent 2a9d413 commit 9f214aa

18 files changed

+30
-194
lines changed

src/CONST.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3732,7 +3732,6 @@ const CONST = {
37323732
TAG: 'tag',
37333733
TAX_RATE: 'taxRate',
37343734
TAX_AMOUNT: 'taxAmount',
3735-
REIMBURSABLE: 'reimbursable',
37363735
REPORT: 'report',
37373736
},
37383737
FOOTER: {

src/components/MoneyRequestConfirmationList.tsx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,6 @@ type MoneyRequestConfirmationListProps = {
179179

180180
/** The PDF password callback */
181181
onPDFPassword?: () => void;
182-
183-
/** Function to toggle reimbursable */
184-
onToggleReimbursable?: (isOn: boolean) => void;
185-
186-
/** Flag indicating if the IOU is reimbursable */
187-
iouIsReimbursable?: boolean;
188182
};
189183

190184
type MoneyRequestConfirmationListItem = Participant | OptionData;
@@ -225,8 +219,6 @@ function MoneyRequestConfirmationList({
225219
isConfirming,
226220
onPDFLoadError,
227221
onPDFPassword,
228-
iouIsReimbursable = true,
229-
onToggleReimbursable,
230222
}: MoneyRequestConfirmationListProps) {
231223
const [policyCategoriesReal] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}${policyID}`, {canBeMissing: true});
232224
const [policyTags] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`, {canBeMissing: true});
@@ -1085,8 +1077,6 @@ function MoneyRequestConfirmationList({
10851077
unit={unit}
10861078
onPDFLoadError={onPDFLoadError}
10871079
onPDFPassword={onPDFPassword}
1088-
iouIsReimbursable={iouIsReimbursable}
1089-
onToggleReimbursable={onToggleReimbursable}
10901080
isReceiptEditable={isReceiptEditable}
10911081
/>
10921082
);

src/components/MoneyRequestConfirmationListFooter.tsx

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import {
2525
getTaxAmount,
2626
getTaxName,
2727
isAmountMissing,
28-
isCardTransaction,
2928
isCreatedMissing,
3029
isFetchingWaypointsFromServer,
3130
shouldShowAttendees as shouldShowAttendeesTransactionUtils,
@@ -197,12 +196,6 @@ type MoneyRequestConfirmationListFooterProps = {
197196

198197
/** The PDF password callback */
199198
onPDFPassword?: () => void;
200-
201-
/** Function to toggle reimbursable */
202-
onToggleReimbursable?: (isOn: boolean) => void;
203-
204-
/** Flag indicating if the IOU is reimbursable */
205-
iouIsReimbursable: boolean;
206199
};
207200

208201
function MoneyRequestConfirmationListFooter({
@@ -253,8 +246,6 @@ function MoneyRequestConfirmationListFooter({
253246
unit,
254247
onPDFLoadError,
255248
onPDFPassword,
256-
iouIsReimbursable,
257-
onToggleReimbursable,
258249
isReceiptEditable = false,
259250
}: MoneyRequestConfirmationListFooterProps) {
260251
const styles = useThemeStyles();
@@ -321,7 +312,6 @@ function MoneyRequestConfirmationListFooter({
321312
const canModifyTaxFields = !isReadOnly && !isDistanceRequest && !isPerDiemRequest;
322313
// A flag for showing the billable field
323314
const shouldShowBillable = policy?.disabledFields?.defaultBillable === false;
324-
const shouldShowReimbursable = policy?.disabledFields?.reimbursable === false && !isCardTransaction(transaction);
325315
// Do not hide fields in case of paying someone
326316
const shouldShowAllFields = !!isPerDiemRequest || !!isDistanceRequest || shouldExpandFields || !shouldShowSmartScanFields || isTypeSend || !!isEditingSplitBill;
327317
// Calculate the formatted tax amount based on the transaction's tax amount and the IOU currency code
@@ -646,25 +636,6 @@ function MoneyRequestConfirmationListFooter({
646636
shouldShow: shouldShowAttendees,
647637
isSupplementary: true,
648638
},
649-
{
650-
item: (
651-
<View
652-
key={Str.UCFirst(translate('iou.reimbursable'))}
653-
style={[styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, styles.ml5, styles.mr8, styles.optionRow]}
654-
>
655-
<ToggleSettingOptionRow
656-
switchAccessibilityLabel={Str.UCFirst(translate('iou.reimbursable'))}
657-
title={Str.UCFirst(translate('iou.reimbursable'))}
658-
onToggle={(isOn) => onToggleReimbursable?.(isOn)}
659-
isActive={iouIsReimbursable}
660-
disabled={isReadOnly}
661-
wrapperStyle={styles.flex1}
662-
/>
663-
</View>
664-
),
665-
shouldShow: shouldShowReimbursable,
666-
isSupplementary: true,
667-
},
668639
{
669640
item: (
670641
<View

src/components/ReportActionItem/MoneyRequestView.tsx

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {Str} from 'expensify-common';
21
import mapValues from 'lodash/mapValues';
32
import React, {useCallback, useMemo, useState} from 'react';
43
import {View} from 'react-native';
@@ -52,7 +51,6 @@ import {
5251
getBillable,
5352
getDescription,
5453
getDistanceInMeters,
55-
getReimbursable,
5654
getTagForDisplay,
5755
getTaxName,
5856
hasMissingSmartscanFields,
@@ -68,7 +66,7 @@ import {
6866
import ViolationsUtils from '@libs/Violations/ViolationsUtils';
6967
import Navigation from '@navigation/Navigation';
7068
import AnimatedEmptyStateBackground from '@pages/home/report/AnimatedEmptyStateBackground';
71-
import {cleanUpMoneyRequest, updateMoneyRequestBillable, updateMoneyRequestReimbursable} from '@userActions/IOU';
69+
import {cleanUpMoneyRequest, updateMoneyRequestBillable} from '@userActions/IOU';
7270
import {navigateToConciergeChatAndDeleteReport} from '@userActions/Report';
7371
import {clearAllRelatedReportActionErrors} from '@userActions/ReportActions';
7472
import {clearError, getLastModifiedExpense, revert} from '@userActions/Transaction';
@@ -155,7 +153,6 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals
155153
currency: transactionCurrency,
156154
comment: transactionDescription,
157155
merchant: transactionMerchant,
158-
reimbursable: transactionReimbursable,
159156
billable: transactionBillable,
160157
category: transactionCategory,
161158
tag: transactionTag,
@@ -233,9 +230,6 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals
233230
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
234231
const shouldShowTag = isPolicyExpenseChat && (transactionTag || hasEnabledTags(policyTagLists));
235232
const shouldShowBillable = isPolicyExpenseChat && (!!transactionBillable || !(policy?.disabledFields?.defaultBillable ?? true) || !!updatedTransaction?.billable);
236-
const shouldShowReimbursable =
237-
isPolicyExpenseChat && (!!transactionReimbursable || !(policy?.disabledFields?.reimbursable ?? true) || !!updatedTransaction?.reimbursable) && !isCardTransaction;
238-
const canEditReimbursable = canUserPerformWriteAction && canEditFieldOfMoneyRequest(parentReportAction, CONST.EDIT_REQUEST_FIELD.REIMBURSABLE);
239233
const shouldShowAttendees = useMemo(() => shouldShowAttendeesTransactionUtils(iouType, policy), [iouType, policy]);
240234

241235
const shouldShowTax = isTaxTrackingEnabled(isPolicyExpenseChat, policy, isDistanceRequest, isPerDiemRequest);
@@ -285,17 +279,6 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals
285279
[transaction, report, policy, policyTagList, policyCategories],
286280
);
287281

288-
const saveReimbursable = useCallback(
289-
(newReimbursable: boolean) => {
290-
// If the value hasn't changed, don't request to save changes on the server and just close the modal
291-
if (newReimbursable === getReimbursable(transaction) || !transaction?.transactionID || !report?.reportID) {
292-
return;
293-
}
294-
updateMoneyRequestReimbursable(transaction.transactionID, report?.reportID, newReimbursable, policy, policyTagList, policyCategories);
295-
},
296-
[transaction, report, policy, policyTagList, policyCategories],
297-
);
298-
299282
if (isCardTransaction) {
300283
if (transactionPostedDate) {
301284
dateDescription += ` ${CONST.DOT_SEPARATOR} ${translate('iou.posted')} ${transactionPostedDate}`;
@@ -817,19 +800,6 @@ function MoneyRequestView({report, shouldShowAnimatedBackground, readonly = fals
817800
/>
818801
</OfflineWithFeedback>
819802
)}
820-
{shouldShowReimbursable && (
821-
<View style={[styles.flexRow, styles.optionRow, styles.justifyContentBetween, styles.alignItemsCenter, styles.ml5, styles.mr8]}>
822-
<View>
823-
<Text>{Str.UCFirst(translate('iou.reimbursable'))}</Text>
824-
</View>
825-
<Switch
826-
accessibilityLabel={Str.UCFirst(translate('iou.reimbursable'))}
827-
isOn={updatedTransaction?.reimbursable ?? !!transactionReimbursable}
828-
onToggle={saveReimbursable}
829-
disabled={!canEditReimbursable}
830-
/>
831-
</View>
832-
)}
833803
{/* Note: "Billable" toggle and "View trip details" should be always the last two items */}
834804
{shouldShowBillable && (
835805
<View style={[styles.flexRow, styles.optionRow, styles.justifyContentBetween, styles.alignItemsCenter, styles.ml5, styles.mr8]}>

src/libs/API/parameters/CreateDistanceRequestParams.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ type CreateDistanceRequestParams = {
1515
taxCode?: string;
1616
taxAmount?: number;
1717
billable?: boolean;
18-
reimbursable?: boolean;
1918
transactionThreadReportID?: string;
2019
createdReportActionIDForThread?: string;
2120
payerEmail?: string;

src/libs/API/parameters/CreatePerDiemRequestParams.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ type CreatePerDiemRequestParams = {
2020
transactionThreadReportID: string;
2121
createdReportActionIDForThread: string | undefined;
2222
billable?: boolean;
23-
reimbursable?: boolean;
2423
attendees?: string;
2524
};
2625

src/libs/API/parameters/RequestMoneyParams.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type RequestMoneyParams = {
2727
receiptGpsPoints?: string;
2828
transactionThreadReportID: string;
2929
createdReportActionIDForThread: string | undefined;
30-
reimbursable?: boolean;
30+
reimbursible?: boolean;
3131
description?: string;
3232
attendees?: string;
3333
};

src/libs/API/parameters/SplitBillParams.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ type SplitBillParams = {
99
category: string;
1010
tag: string;
1111
billable: boolean;
12-
reimbursable: boolean;
1312
transactionID: string;
1413
reportActionID: string;
1514
createdReportActionID?: string;

src/libs/API/parameters/StartSplitBillParams.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ type StartSplitBillParams = {
1313
isFromGroupDM: boolean;
1414
createdReportActionID?: string;
1515
billable: boolean;
16-
reimbursable: boolean;
1716
chatType?: string;
1817
taxCode?: string;
1918
taxAmount?: number;

src/libs/API/types.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ const WRITE_COMMANDS = {
188188
COMPLETE_SPLIT_BILL: 'CompleteSplitBill',
189189
UPDATE_MONEY_REQUEST_ATTENDEES: 'UpdateMoneyRequestAttendees',
190190
UPDATE_MONEY_REQUEST_DATE: 'UpdateMoneyRequestDate',
191-
UPDATE_MONEY_REQUEST_REIMBURSABLE: 'UpdateMoneyRequestReimbursable',
192191
UPDATE_MONEY_REQUEST_BILLABLE: 'UpdateMoneyRequestBillable',
193192
UPDATE_MONEY_REQUEST_MERCHANT: 'UpdateMoneyRequestMerchant',
194193
UPDATE_MONEY_REQUEST_TAG: 'UpdateMoneyRequestTag',
@@ -656,7 +655,6 @@ type WriteCommandParameters = {
656655
[WRITE_COMMANDS.UPDATE_MONEY_REQUEST_ATTENDEES]: Parameters.UpdateMoneyRequestParams;
657656
[WRITE_COMMANDS.UPDATE_MONEY_REQUEST_DATE]: Parameters.UpdateMoneyRequestParams;
658657
[WRITE_COMMANDS.UPDATE_MONEY_REQUEST_MERCHANT]: Parameters.UpdateMoneyRequestParams;
659-
[WRITE_COMMANDS.UPDATE_MONEY_REQUEST_REIMBURSABLE]: Parameters.UpdateMoneyRequestParams;
660658
[WRITE_COMMANDS.UPDATE_MONEY_REQUEST_BILLABLE]: Parameters.UpdateMoneyRequestParams;
661659
[WRITE_COMMANDS.UPDATE_MONEY_REQUEST_TAG]: Parameters.UpdateMoneyRequestParams;
662660
[WRITE_COMMANDS.UPDATE_MONEY_REQUEST_TAX_AMOUNT]: Parameters.UpdateMoneyRequestParams;

src/libs/ModifiedExpenseMessage.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ Onyx.connect({
3636
callback: (value) => (allReports = value),
3737
});
3838

39+
/**
40+
* Utility to get message based on boolean literal value.
41+
*/
42+
function getBooleanLiteralMessage(value: string | undefined, truthyMessage: string, falsyMessage: string): string {
43+
return value === 'true' ? truthyMessage : falsyMessage;
44+
}
45+
3946
/**
4047
* Builds the partial message fragment for a modified field on the expense.
4148
*/
@@ -327,8 +334,8 @@ function getForReportAction({
327334
const hasModifiedReimbursable = isReportActionOriginalMessageAnObject && 'oldReimbursable' in reportActionOriginalMessage && 'reimbursable' in reportActionOriginalMessage;
328335
if (hasModifiedReimbursable) {
329336
buildMessageFragmentForValue(
330-
reportActionOriginalMessage?.reimbursable ?? '',
331-
reportActionOriginalMessage?.oldReimbursable ?? '',
337+
getBooleanLiteralMessage(reportActionOriginalMessage?.reimbursable, translateLocal('iou.reimbursable'), translateLocal('iou.nonReimbursable')),
338+
getBooleanLiteralMessage(reportActionOriginalMessage?.oldReimbursable, translateLocal('iou.reimbursable'), translateLocal('iou.nonReimbursable')),
332339
translateLocal('iou.expense'),
333340
true,
334341
setFragments,

src/libs/ReportUtils.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,6 @@ type TransactionDetails = {
660660
customUnitRateID?: string;
661661
comment: string;
662662
category: string;
663-
reimbursable: boolean;
664663
billable: boolean;
665664
tag: string;
666665
mccGroup?: ValueOf<typeof CONST.MCC_GROUPS>;
@@ -3734,7 +3733,6 @@ function getTransactionDetails(
37343733
waypoints: getWaypoints(transaction),
37353734
customUnitRateID: getRateID(transaction),
37363735
category: getCategory(transaction),
3737-
reimbursable: getReimbursable(transaction),
37383736
billable: getBillable(transaction),
37393737
tag: getTag(transaction),
37403738
mccGroup: getMCCGroup(transaction),
@@ -3838,7 +3836,6 @@ function canEditFieldOfMoneyRequest(reportAction: OnyxInputOrEntry<ReportAction>
38383836
CONST.EDIT_REQUEST_FIELD.RECEIPT,
38393837
CONST.EDIT_REQUEST_FIELD.DISTANCE,
38403838
CONST.EDIT_REQUEST_FIELD.DISTANCE_RATE,
3841-
CONST.EDIT_REQUEST_FIELD.REIMBURSABLE,
38423839
CONST.EDIT_REQUEST_FIELD.REPORT,
38433840
];
38443841

@@ -4380,12 +4377,6 @@ function getModifiedExpenseOriginalMessage(
43804377
originalMessage.currency = getCurrency(oldTransaction);
43814378
}
43824379

4383-
if ('reimbursable' in transactionChanges) {
4384-
const oldReimbursable = getReimbursable(oldTransaction);
4385-
originalMessage.oldReimbursable = oldReimbursable ? translateLocal('common.reimbursable').toLowerCase() : translateLocal('iou.nonReimbursable').toLowerCase();
4386-
originalMessage.reimbursable = transactionChanges?.reimbursable ? translateLocal('common.reimbursable').toLowerCase() : translateLocal('iou.nonReimbursable').toLowerCase();
4387-
}
4388-
43894380
if ('billable' in transactionChanges) {
43904381
const oldBillable = getBillable(oldTransaction);
43914382
originalMessage.oldBillable = oldBillable ? translateLocal('common.billable').toLowerCase() : translateLocal('common.nonBillable').toLowerCase();

src/libs/TransactionUtils/index.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,6 @@ function getUpdatedTransaction({
486486
updatedTransaction.taxCode = transactionChanges.taxCode;
487487
}
488488

489-
if (Object.hasOwn(transactionChanges, 'reimbursable') && typeof transactionChanges.reimbursable === 'boolean') {
490-
updatedTransaction.reimbursable = transactionChanges.reimbursable;
491-
}
492-
493489
if (Object.hasOwn(transactionChanges, 'billable') && typeof transactionChanges.billable === 'boolean') {
494490
updatedTransaction.billable = transactionChanges.billable;
495491
}
@@ -530,7 +526,6 @@ function getUpdatedTransaction({
530526
...(Object.hasOwn(transactionChanges, 'currency') && {currency: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}),
531527
...(Object.hasOwn(transactionChanges, 'merchant') && {merchant: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}),
532528
...(Object.hasOwn(transactionChanges, 'waypoints') && {waypoints: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}),
533-
...(Object.hasOwn(transactionChanges, 'reimbursable') && {reimbursable: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}),
534529
...(Object.hasOwn(transactionChanges, 'billable') && {billable: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}),
535530
...(Object.hasOwn(transactionChanges, 'category') && {category: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}),
536531
...(Object.hasOwn(transactionChanges, 'tag') && {tag: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE}),
@@ -689,7 +684,7 @@ function getFormattedAttendees(modifiedAttendees?: Attendee[], attendees?: Atten
689684
/**
690685
* Return the reimbursable value. Defaults to true to match BE logic.
691686
*/
692-
function getReimbursable(transaction: OnyxInputOrEntry<Transaction>): boolean {
687+
function getReimbursable(transaction: Transaction): boolean {
693688
return transaction?.reimbursable ?? true;
694689
}
695690

0 commit comments

Comments
 (0)