Skip to content

Commit 030c5f3

Browse files
committed
migrate updateMoneyRequestAmountAndCurrency
1 parent 9105cc4 commit 030c5f3

6 files changed

Lines changed: 18 additions & 3 deletions

File tree

config/eslint/eslint.seatbelt.tsv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@
831831
"../../src/libs/actions/IOU/TrackExpense.ts" "@typescript-eslint/no-unsafe-type-assertion" 2
832832
"../../src/libs/actions/IOU/TrackExpense.ts" "no-restricted-syntax" 2
833833
"../../src/libs/actions/IOU/UpdateMoneyRequest.ts" "@typescript-eslint/no-deprecated/buildNextStepNew" 1
834-
"../../src/libs/actions/IOU/UpdateMoneyRequest.ts" "@typescript-eslint/no-deprecated/getPolicyTagsData" 13
834+
"../../src/libs/actions/IOU/UpdateMoneyRequest.ts" "@typescript-eslint/no-deprecated/getPolicyTagsData" 12
835835
"../../src/libs/actions/IOU/UpdateMoneyRequest.ts" "@typescript-eslint/no-unsafe-type-assertion" 2
836836
"../../src/libs/actions/IOU/UpdateMoneyRequest.ts" "no-restricted-syntax" 1
837837
"../../src/libs/actions/IOU/index.ts" "@typescript-eslint/no-deprecated/getMoneyRequestPolicyTags" 1

src/libs/actions/IOU/UpdateMoneyRequest.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,7 @@ type UpdateMoneyRequestAmountAndCurrencyParams = {
12611261
parentReportNextStep: OnyxEntry<OnyxTypes.ReportNextStepDeprecated>;
12621262
hash?: number;
12631263
delegateAccountID: number | undefined;
1264+
reportPolicyTags: OnyxEntry<OnyxTypes.PolicyTagLists>;
12641265
};
12651266

12661267
/** Updates the amount and currency fields of an expense */
@@ -1286,6 +1287,7 @@ function updateMoneyRequestAmountAndCurrency({
12861287
parentReportNextStep,
12871288
hash,
12881289
delegateAccountID,
1290+
reportPolicyTags,
12891291
}: UpdateMoneyRequestAmountAndCurrencyParams) {
12901292
const transactionChanges = {
12911293
amount,
@@ -1307,8 +1309,7 @@ function updateMoneyRequestAmountAndCurrency({
13071309
transactionChanges,
13081310
policy,
13091311
policyTagList,
1310-
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
1311-
reportPolicyTags: getPolicyTagsData(parentReport?.policyID),
1312+
reportPolicyTags,
13121313
policyCategories: policyCategories ?? null,
13131314
allowNegative,
13141315
currentUserAccountIDParam,

src/libs/actions/TransactionInlineEdit.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import type {
5454
Transaction,
5555
TransactionViolations,
5656
} from '@src/types/onyx';
57+
import {getPolicyTagsData} from './IOU';
5758
import {
5859
updateMoneyRequestAmountAndCurrency,
5960
updateMoneyRequestCategory,
@@ -355,6 +356,9 @@ function editTransactionAmountInline(params: TransactionInlineEditParams, newAmo
355356
const taxPercentage = getTaxValue(iouParams.policy, iouParams.transaction, taxCode) ?? '';
356357
const decimals = getCurrencyDecimals(getCurrency(iouParams.transaction));
357358
const taxAmount = convertToBackendAmount(calculateTaxAmount(taxPercentage, newAmount, decimals));
359+
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
360+
// eslint-disable-next-line @typescript-eslint/no-deprecated
361+
const reportPolicyTags = getPolicyTagsData(iouParams.parentReport?.policyID);
358362
updateMoneyRequestAmountAndCurrency({
359363
...iouParams,
360364
amount: newAmount,
@@ -367,6 +371,7 @@ function editTransactionAmountInline(params: TransactionInlineEditParams, newAmo
367371
transactionViolations: allTransactionViolations,
368372
policyRecentlyUsedCurrencies: [],
369373
hash: params.hash,
374+
reportPolicyTags,
370375
});
371376
}
372377

src/pages/iou/request/step/AmountSubmission.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import Permissions from '@libs/Permissions';
2121
import {getPolicyExpenseChat, getTransactionDetails, isMoneyRequestReport, isSelfDM, shouldEnableNegative} from '@libs/ReportUtils';
2222
import shouldUseDefaultExpensePolicy from '@libs/shouldUseDefaultExpensePolicy';
2323
import {calculateTaxAmount, getAmount, getCurrency, getDefaultTaxCode, getIsFromGlobalCreate, getTaxValue, hasReceipt} from '@libs/TransactionUtils';
24+
import {getPolicyTagsData} from '@userActions/IOU';
2425
import {
2526
getMoneyRequestParticipantsFromReport,
2627
setMoneyRequestAmount,
@@ -544,6 +545,9 @@ function submitAmount({
544545
// `TRANSACTION_VIOLATIONS` at module scope.
545546
const parentReport = report?.parentReportID ? allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${report.parentReportID}`] : undefined;
546547

548+
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
549+
// eslint-disable-next-line @typescript-eslint/no-deprecated
550+
const reportPolicyTags = getPolicyTagsData(parentReport?.policyID);
547551
updateMoneyRequestAmountAndCurrency({
548552
transactionID,
549553
transactionThreadReport: report,
@@ -563,6 +567,7 @@ function submitAmount({
563567
isASAPSubmitBetaEnabled,
564568
policyRecentlyUsedCurrencies: policyRecentlyUsedCurrencies ?? [],
565569
delegateAccountID,
570+
reportPolicyTags,
566571
});
567572
navigateBack();
568573
}

tests/actions/IOUTest/DeleteMoneyRequestTest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,7 @@ describe('actions/IOU/DeleteMoneyRequest', () => {
677677
transactionThreadReport: thread,
678678
parentReport: iouReport,
679679
transactionViolations: {},
680+
reportPolicyTags: undefined,
680681
amount: 20000,
681682
currency: CONST.CURRENCY.USD,
682683
taxAmount: 0,

tests/actions/IOUTest/UpdateMoneyRequestTest.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ describe('actions/IOU/UpdateMoneyRequest', () => {
406406
transactionID: fakeTransaction.transactionID,
407407
transactionThreadReport: fakeReport,
408408
parentReport: undefined,
409+
reportPolicyTags: undefined,
409410
amount: 20000,
410411
currency: CONST.CURRENCY.USD,
411412
taxAmount: 0,
@@ -477,6 +478,7 @@ describe('actions/IOU/UpdateMoneyRequest', () => {
477478
transactionID: fakeTransaction.transactionID,
478479
transactionThreadReport: fakeReport,
479480
parentReport: undefined,
481+
reportPolicyTags: undefined,
480482
amount: 20000,
481483
currency: CONST.CURRENCY.USD,
482484
taxAmount: 0,
@@ -631,6 +633,7 @@ describe('actions/IOU/UpdateMoneyRequest', () => {
631633
transactionID,
632634
transactionThreadReport: transactionThread,
633635
parentReport: expenseReport,
636+
reportPolicyTags: undefined,
634637
amount: 20000,
635638
currency: CONST.CURRENCY.USD,
636639
taxAmount: 0,

0 commit comments

Comments
 (0)