-
Notifications
You must be signed in to change notification settings - Fork 4k
refactor: move getPolicyTagsData to IOU and Transaction files #72678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
youssef-lr
merged 45 commits into
Expensify:main
from
software-mansion-labs:@Skalakid/refactor/useonyx-deprecate-onyx-connect/getPolicyTagsData-src-libs-actions-Policy-Tag.ts
Jan 27, 2026
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
17917f8
refactor: move getPolicyTagsData to IOU and Transaction files
Skalakid b08a9a5
fix: move Onyx.connect temporarily to TransactionUtils
Skalakid d293bdf
fix: update link to the issues in TODO comments in Transaction.ts
Skalakid b2fae7c
fix: remove getPolicyTagsData export
Skalakid 5978bbf
refactor: update issue urls
Skalakid c676eea
Merge branch 'main' into @Skalakid/refactor/useonyx-deprecate-onyx-co…
Skalakid 0efdb55
fix: fix eslint errors
Skalakid 4a0f467
Merge branch 'main' into @Skalakid/refactor/useonyx-deprecate-onyx-co…
Skalakid 36619a9
Merge branch 'main' into @Skalakid/refactor/useonyx-deprecate-onyx-co…
Skalakid 6ae91eb
Merge branch 'main' into @Skalakid/refactor/useonyx-deprecate-onyx-co…
dariusz-biela bdf606c
feat: removes Onyx.connect for ONYXKEYS.COLLECTION.POLICY_TAGS in src…
dariusz-biela f2b062d
fix: removes unused import
dariusz-biela 113db07
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 a95a1b0
dont push mobile exp
Guccio163 0187e5d
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 7a690ab
fix merge
Guccio163 7b439fe
adding allPolicyTags Onyx.connect to necessary files
Guccio163 7ef57db
fixing comments about deprecation
Guccio163 348fbab
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 7289d0b
Apply suggestion from @dariusz-biela
Guccio163 e5ccebe
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 8d4bf20
update issues links
Guccio163 dcae657
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 ad33d41
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 a3319bd
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 238dc4f
add no-deprecated annotations
Guccio163 bfc5b63
update max-warnings
Guccio163 32e5f0e
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 9ca99c7
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 73d245b
Mobile
Guccio163 4298e80
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 6e70379
migrating also to Split.ts
Guccio163 13d34d8
prettier
Guccio163 766ea1b
Split issue update
Guccio163 96d6826
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 2f63889
update Mobile
Guccio163 0952df6
Merge branch '@Skalakid/refactor/useonyx-deprecate-onyx-connect/getPo…
Guccio163 21e3cae
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 89a384a
bump max-warnings
Guccio163 0a7b0be
use getPolicyTags from IOU/index.ts
Guccio163 c544d6e
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 94c2272
fix TODO comments
Guccio163 5df43b7
fix imports
Guccio163 d0ac3a2
bring back Onyx.connect to TransactionUtils to fix tests
Guccio163 debca04
Merge branch 'main' of github.com:software-mansion-labs/expensify-app…
Guccio163 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -224,7 +224,7 @@ | |
| import {clearByKey as clearPdfByOnyxKey} from '@userActions/CachedPDFPaths'; | ||
| import {buildAddMembersToWorkspaceOnyxData, buildUpdateWorkspaceMembersRoleOnyxData} from '@userActions/Policy/Member'; | ||
| import {buildPolicyData, generatePolicyID} from '@userActions/Policy/Policy'; | ||
| import {buildOptimisticPolicyRecentlyUsedTags, getPolicyTagsData} from '@userActions/Policy/Tag'; | ||
| import {buildOptimisticPolicyRecentlyUsedTags} from '@userActions/Policy/Tag'; | ||
| import type {GuidedSetupData} from '@userActions/Report'; | ||
| import {buildInviteToRoomOnyxData, completeOnboarding, getCurrentUserAccountID, notifyNewAction, optimisticReportLastData} from '@userActions/Report'; | ||
| import {clearAllRelatedReportActionErrors} from '@userActions/ReportActions'; | ||
|
|
@@ -759,7 +759,7 @@ | |
| }; | ||
|
|
||
| let allPersonalDetails: OnyxTypes.PersonalDetailsList = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
| callback: (value) => { | ||
| allPersonalDetails = value ?? {}; | ||
|
|
@@ -837,7 +837,7 @@ | |
| }; | ||
|
|
||
| let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.TRANSACTION, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -851,7 +851,7 @@ | |
| }); | ||
|
|
||
| let allTransactionDrafts: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -860,7 +860,7 @@ | |
| }); | ||
|
|
||
| let allTransactionViolations: NonNullable<OnyxCollection<OnyxTypes.TransactionViolations>> = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -873,8 +873,21 @@ | |
| }, | ||
| }); | ||
|
|
||
| let allPolicyTags: OnyxCollection<OnyxTypes.PolicyTagLists> = {}; | ||
| Onyx.connect({ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @tgolen Create one issue for this too and assign me there.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'll be resolved in #72721 |
||
| key: ONYXKEYS.COLLECTION.POLICY_TAGS, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
| if (!value) { | ||
| allPolicyTags = {}; | ||
| return; | ||
| } | ||
| allPolicyTags = value; | ||
| }, | ||
| }); | ||
|
|
||
| let allReports: OnyxCollection<OnyxTypes.Report>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.REPORT, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -883,7 +896,7 @@ | |
| }); | ||
|
|
||
| let allReportNameValuePairs: OnyxCollection<OnyxTypes.ReportNameValuePairs>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -893,7 +906,7 @@ | |
|
|
||
| let userAccountID = -1; | ||
| let currentUserEmail = ''; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.SESSION, | ||
| callback: (value) => { | ||
| currentUserEmail = value?.email ?? ''; | ||
|
|
@@ -902,7 +915,7 @@ | |
| }); | ||
|
|
||
| let deprecatedCurrentUserPersonalDetails: OnyxEntry<OnyxTypes.PersonalDetails>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
| callback: (value) => { | ||
| deprecatedCurrentUserPersonalDetails = value?.[userAccountID] ?? undefined; | ||
|
|
@@ -971,6 +984,19 @@ | |
| return userAccountID; | ||
| } | ||
|
|
||
| function getPolicyTags(): OnyxCollection<OnyxTypes.PolicyTagLists> { | ||
| return allPolicyTags; | ||
| } | ||
|
|
||
| /** | ||
| * @deprecated This function uses Onyx.connect and should be replaced with useOnyx for reactive data access. | ||
| * TODO: remove `getPolicyTagsData` from this file (https://github.com/Expensify/App/issues/72721) | ||
| * All usages of this function should be replaced with useOnyx hook in React components. | ||
| */ | ||
| function getPolicyTagsData(policyID: string | undefined) { | ||
| return allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${policyID}`] ?? {}; | ||
| } | ||
|
|
||
| /** | ||
| * @private | ||
| * After finishing the action in RHP from the Inbox tab, besides dismissing the modal, we should open the report. | ||
|
|
@@ -3209,6 +3235,8 @@ | |
|
|
||
| const optimisticPolicyRecentlyUsedCategories = mergePolicyRecentlyUsedCategories(category, policyRecentlyUsedCategories); | ||
| const optimisticPolicyRecentlyUsedTags = buildOptimisticPolicyRecentlyUsedTags({ | ||
| // TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) and getPolicyRecentlyUsedTagsData (https://github.com/Expensify/App/issues/71491) with useOnyx hook | ||
| // eslint-disable-next-line @typescript-eslint/no-deprecated | ||
| policyTags: getPolicyTagsData(iouReport.policyID), | ||
| policyRecentlyUsedTags, | ||
| transactionTags: tag, | ||
|
|
@@ -3562,6 +3590,8 @@ | |
| optimisticTransaction.hasEReceipt = true; | ||
| const optimisticPolicyRecentlyUsedCategories = mergePolicyRecentlyUsedCategories(category, policyRecentlyUsedCategories); | ||
| const optimisticPolicyRecentlyUsedTags = buildOptimisticPolicyRecentlyUsedTags({ | ||
| // TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) and getPolicyRecentlyUsedTagsData (https://github.com/Expensify/App/issues/71491) with useOnyx hook | ||
| // eslint-disable-next-line @typescript-eslint/no-deprecated | ||
| policyTags: getPolicyTagsData(iouReport.policyID), | ||
| policyRecentlyUsedTags, | ||
| transactionTags: tag, | ||
|
|
@@ -4399,6 +4429,8 @@ | |
| const hasModifiedTag = 'tag' in transactionChanges; | ||
| if (hasModifiedTag) { | ||
| const optimisticPolicyRecentlyUsedTags = buildOptimisticPolicyRecentlyUsedTags({ | ||
| // TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) and getPolicyRecentlyUsedTagsData (https://github.com/Expensify/App/issues/71491) with useOnyx hook | ||
| // eslint-disable-next-line @typescript-eslint/no-deprecated | ||
| policyTags: getPolicyTagsData(iouReport?.policyID), | ||
| policyRecentlyUsedTags, | ||
| transactionTags: transactionChanges.tag, | ||
|
|
@@ -7303,6 +7335,8 @@ | |
| // Add tag to optimistic policy recently used tags when a participant is a workspace | ||
| const optimisticPolicyRecentlyUsedTags = isPolicyExpenseChat | ||
| ? buildOptimisticPolicyRecentlyUsedTags({ | ||
| // TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) and getPolicyRecentlyUsedTagsData (https://github.com/Expensify/App/issues/71491) with useOnyx hook | ||
| // eslint-disable-next-line @typescript-eslint/no-deprecated | ||
| policyTags: getPolicyTagsData(participant.policyID), | ||
| policyRecentlyUsedTags, | ||
| transactionTags: tag, | ||
|
|
@@ -11005,6 +11039,8 @@ | |
| ]; | ||
|
|
||
| if (transactionPolicy && isPaidGroupPolicy(transactionPolicy) && newTransaction) { | ||
| // TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) and getPolicyRecentlyUsedTagsData (https://github.com/Expensify/App/issues/71491) with useOnyx hook | ||
| // eslint-disable-next-line @typescript-eslint/no-deprecated | ||
| const policyTagList = getPolicyTagsData(transactionPolicy.id); | ||
| const currentTransactionViolations = allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`] ?? []; | ||
| const violationsOnyxData = ViolationsUtils.getViolationsOnyxData( | ||
|
|
@@ -11130,6 +11166,8 @@ | |
| ]; | ||
|
|
||
| if (transactionPolicy && isPaidGroupPolicy(transactionPolicy) && newTransaction) { | ||
| // TODO: Replace getPolicyTagsData (https://github.com/Expensify/App/issues/72721) and getPolicyRecentlyUsedTagsData (https://github.com/Expensify/App/issues/71491) with useOnyx hook | ||
| // eslint-disable-next-line @typescript-eslint/no-deprecated | ||
| const policyTagList = getPolicyTagsData(transactionPolicy.id); | ||
| const currentTransactionViolations = allTransactionViolations[`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`] ?? []; | ||
| const violationsOnyxData = ViolationsUtils.getViolationsOnyxData( | ||
|
|
@@ -13136,6 +13174,7 @@ | |
| getUserAccountID, | ||
| getReceiptError, | ||
| getSearchOnyxUpdate, | ||
| getPolicyTags, | ||
| setMoneyRequestTimeRate, | ||
| setMoneyRequestTimeCount, | ||
| buildMinimalTransactionForFormula, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.