Skip to content

Commit 78a08f1

Browse files
authored
Merge pull request #88302 from software-mansion-labs/Guccio163/onyx-connect/policy_tags/getUpdateMoneyRequestParams
Remove Onyx.connect() usage for ONYXKEYS.COLLECTION.POLICY_TAGS in getUpdateMoneyRequestParams function from src/libs/actions/IOU/UpdateMoneyRequest.ts
2 parents ff38b08 + c0df4a0 commit 78a08f1

5 files changed

Lines changed: 333 additions & 4 deletions

File tree

src/libs/actions/IOU/Split.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,6 +1580,9 @@ function updateSplitTransactions({
15801580
transactionChanges,
15811581
policy,
15821582
policyTagList: policyTags ?? null,
1583+
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
1584+
// eslint-disable-next-line @typescript-eslint/no-deprecated
1585+
reportPolicyTags: getPolicyTagsData(transactionIOUReport?.policyID),
15831586
policyCategories: policyCategories ?? null,
15841587
newTransactionReportID: splitExpense?.reportID,
15851588
policyRecentlyUsedCategories,

src/libs/actions/IOU/UpdateMoneyRequest.ts

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ function updateMoneyRequestDate({
104104
transactionChanges,
105105
policy,
106106
policyTagList: policyTags,
107+
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
108+
// eslint-disable-next-line @typescript-eslint/no-deprecated
109+
reportPolicyTags: getPolicyTagsData(parentReport?.policyID),
107110
policyCategories,
108111
currentUserAccountIDParam,
109112
currentUserEmailParam,
@@ -155,6 +158,9 @@ function updateMoneyRequestBillable({
155158
transactionChanges,
156159
policy,
157160
policyTagList,
161+
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
162+
// eslint-disable-next-line @typescript-eslint/no-deprecated
163+
reportPolicyTags: getPolicyTagsData(parentReport?.policyID),
158164
policyCategories,
159165
currentUserAccountIDParam,
160166
currentUserEmailParam,
@@ -202,6 +208,9 @@ function updateMoneyRequestReimbursable({
202208
transactionChanges,
203209
policy,
204210
policyTagList,
211+
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
212+
// eslint-disable-next-line @typescript-eslint/no-deprecated
213+
reportPolicyTags: getPolicyTagsData(parentReport?.policyID),
205214
policyCategories,
206215
currentUserAccountIDParam,
207216
currentUserEmailParam,
@@ -252,6 +261,9 @@ function updateMoneyRequestMerchant({
252261
transactionChanges,
253262
policy,
254263
policyTagList,
264+
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
265+
// eslint-disable-next-line @typescript-eslint/no-deprecated
266+
reportPolicyTags: getPolicyTagsData(parentReport?.policyID),
255267
policyCategories,
256268
currentUserAccountIDParam,
257269
currentUserEmailParam,
@@ -301,6 +313,9 @@ function updateMoneyRequestAttendees({
301313
transactionChanges,
302314
policy,
303315
policyTagList,
316+
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
317+
// eslint-disable-next-line @typescript-eslint/no-deprecated
318+
reportPolicyTags: getPolicyTagsData(parentReport?.policyID),
304319
policyCategories,
305320
violations,
306321
currentUserAccountIDParam,
@@ -354,6 +369,9 @@ function updateMoneyRequestTag({
354369
transactionChanges,
355370
policy,
356371
policyTagList,
372+
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
373+
// eslint-disable-next-line @typescript-eslint/no-deprecated
374+
reportPolicyTags: getPolicyTagsData(parentReport?.policyID),
357375
policyRecentlyUsedTags,
358376
policyCategories,
359377
hash,
@@ -401,6 +419,9 @@ function updateMoneyRequestTaxAmount({
401419
transactionChanges,
402420
policy,
403421
policyTagList,
422+
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
423+
// eslint-disable-next-line @typescript-eslint/no-deprecated
424+
reportPolicyTags: getPolicyTagsData(parentReport?.policyID),
404425
policyCategories,
405426
currentUserAccountIDParam,
406427
currentUserEmailParam,
@@ -454,6 +475,9 @@ function updateMoneyRequestTaxRate({
454475
transactionChanges,
455476
policy,
456477
policyTagList,
478+
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
479+
// eslint-disable-next-line @typescript-eslint/no-deprecated
480+
reportPolicyTags: getPolicyTagsData(parentReport?.policyID),
457481
policyCategories,
458482
currentUserAccountIDParam,
459483
currentUserEmailParam,
@@ -525,6 +549,9 @@ function updateMoneyRequestDistance({
525549
transactionChanges,
526550
policy,
527551
policyTagList,
552+
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
553+
// eslint-disable-next-line @typescript-eslint/no-deprecated
554+
reportPolicyTags: getPolicyTagsData(parentReport?.policyID),
528555
policyCategories,
529556
currentUserAccountIDParam,
530557
currentUserEmailParam,
@@ -625,6 +652,9 @@ function updateMoneyRequestCategory({
625652
transactionChanges,
626653
policy,
627654
policyTagList,
655+
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
656+
// eslint-disable-next-line @typescript-eslint/no-deprecated
657+
reportPolicyTags: getPolicyTagsData(parentReport?.policyID),
628658
policyCategories,
629659
policyRecentlyUsedCategories,
630660
currentUserAccountIDParam,
@@ -678,6 +708,9 @@ function updateMoneyRequestDescription({
678708
transactionChanges,
679709
policy,
680710
policyTagList,
711+
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
712+
// eslint-disable-next-line @typescript-eslint/no-deprecated
713+
reportPolicyTags: getPolicyTagsData(parentReport?.policyID),
681714
policyCategories,
682715
currentUserAccountIDParam,
683716
currentUserEmailParam,
@@ -754,6 +787,9 @@ function updateMoneyRequestDistanceRate({
754787
transactionChanges,
755788
policy,
756789
policyTagList,
790+
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
791+
// eslint-disable-next-line @typescript-eslint/no-deprecated
792+
reportPolicyTags: getPolicyTagsData(parentReport?.policyID),
757793
policyCategories,
758794
currentUserAccountIDParam,
759795
currentUserEmailParam,
@@ -830,7 +866,10 @@ function updateMoneyRequestAmountAndCurrency({
830866
iouReport: parentReport,
831867
transactionChanges,
832868
policy,
833-
policyTagList: policyTagList ?? null,
869+
policyTagList,
870+
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
871+
// eslint-disable-next-line @typescript-eslint/no-deprecated
872+
reportPolicyTags: getPolicyTagsData(parentReport?.policyID),
834873
policyCategories: policyCategories ?? null,
835874
allowNegative,
836875
currentUserAccountIDParam,
@@ -851,6 +890,7 @@ type GetUpdateMoneyRequestParamsType = {
851890
transactionChanges: TransactionChanges;
852891
policy: OnyxEntry<OnyxTypes.Policy>;
853892
policyTagList: OnyxTypes.OnyxInputOrEntry<OnyxTypes.PolicyTagLists>;
893+
reportPolicyTags: OnyxEntry<OnyxTypes.PolicyTagLists>;
854894
policyRecentlyUsedTags?: OnyxEntry<RecentlyUsedTags>;
855895
policyCategories: OnyxTypes.OnyxInputOrEntry<OnyxTypes.PolicyCategories>;
856896
policyRecentlyUsedCategories?: OnyxEntry<OnyxTypes.RecentlyUsedCategories>;
@@ -890,6 +930,7 @@ function getUpdateMoneyRequestParams(params: GetUpdateMoneyRequestParamsType): U
890930
transactionChanges,
891931
policy,
892932
policyTagList,
933+
reportPolicyTags,
893934
policyRecentlyUsedTags,
894935
policyCategories,
895936
policyRecentlyUsedCategories,
@@ -1188,9 +1229,7 @@ function getUpdateMoneyRequestParams(params: GetUpdateMoneyRequestParamsType): U
11881229
const hasModifiedTag = 'tag' in transactionChanges;
11891230
if (hasModifiedTag) {
11901231
const optimisticPolicyRecentlyUsedTags = buildOptimisticPolicyRecentlyUsedTags({
1191-
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) and getPolicyRecentlyUsedTagsData (https://github.com/Expensify/App/issues/71491) with useOnyx hook
1192-
// eslint-disable-next-line @typescript-eslint/no-deprecated
1193-
policyTags: getPolicyTagsData(iouReport?.policyID),
1232+
policyTags: reportPolicyTags ?? {},
11941233
policyRecentlyUsedTags,
11951234
transactionTags: transactionChanges.tag,
11961235
});

src/libs/actions/MergeTransaction.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {isDistanceRequest, isTransactionPendingDelete} from '@src/libs/Transacti
3333
import ONYXKEYS from '@src/ONYXKEYS';
3434
import ROUTES from '@src/ROUTES';
3535
import type {CardList, MergeTransaction, Policy, PolicyCategories, PolicyTagLists, Report, ReportNextStepDeprecated, Transaction, TransactionViolations} from '@src/types/onyx';
36+
import {getPolicyTagsData} from './IOU';
3637
import type {UpdateMoneyRequestData} from './IOU';
3738
import {getCleanUpTransactionThreadReportOnyxData} from './IOU/DeleteMoneyRequest';
3839
import {getDeleteTrackExpenseInformation} from './IOU/TrackExpense';
@@ -271,6 +272,9 @@ function getOnyxTargetTransactionData({
271272
transactionChanges: filteredTransactionChanges,
272273
policy,
273274
policyTagList: policyTags,
275+
// TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) with useOnyx hook
276+
// eslint-disable-next-line @typescript-eslint/no-deprecated
277+
reportPolicyTags: getPolicyTagsData(targetTransactionThreadParentReport?.policyID),
274278
policyCategories,
275279
violations: targetTransactionViolations ?? [],
276280
shouldBuildOptimisticModifiedExpenseReportAction,

0 commit comments

Comments
 (0)