-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[No QA] deprecate session data & refactor getCleanUpTransactionThreadReportOnyxData
#86605
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
Changes from all commits
86063b4
792935f
656e7ee
fffc25a
23c0595
7b5f467
b7c7e0d
1d48951
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -790,7 +790,7 @@ | |
| }; | ||
|
|
||
| let allPersonalDetails: OnyxTypes.PersonalDetailsList = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
| callback: (value) => { | ||
| allPersonalDetails = value ?? {}; | ||
|
|
@@ -923,7 +923,7 @@ | |
| }; | ||
|
|
||
| let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.TRANSACTION, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -937,7 +937,7 @@ | |
| }); | ||
|
|
||
| let allTransactionDrafts: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.TRANSACTION_DRAFT, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -946,7 +946,7 @@ | |
| }); | ||
|
|
||
| let allTransactionViolations: NonNullable<OnyxCollection<OnyxTypes.TransactionViolations>> = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -960,7 +960,7 @@ | |
| }); | ||
|
|
||
| let allPolicyTags: OnyxCollection<OnyxTypes.PolicyTagLists> = {}; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.POLICY_TAGS, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -973,7 +973,7 @@ | |
| }); | ||
|
|
||
| let allReports: OnyxCollection<OnyxTypes.Report>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.REPORT, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -982,7 +982,7 @@ | |
| }); | ||
|
|
||
| let allReportNameValuePairs: OnyxCollection<OnyxTypes.ReportNameValuePairs>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS, | ||
| waitForCollectionCallback: true, | ||
| callback: (value) => { | ||
|
|
@@ -990,26 +990,26 @@ | |
| }, | ||
| }); | ||
|
|
||
| let userAccountID = -1; | ||
| let currentUserEmail = ''; | ||
| let deprecatedUserAccountID = -1; | ||
| let deprecatedCurrentUserEmail = ''; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.SESSION, | ||
| callback: (value) => { | ||
| currentUserEmail = value?.email ?? ''; | ||
| userAccountID = value?.accountID ?? CONST.DEFAULT_NUMBER_ID; | ||
| deprecatedCurrentUserEmail = value?.email ?? ''; | ||
| deprecatedUserAccountID = value?.accountID ?? CONST.DEFAULT_NUMBER_ID; | ||
| }, | ||
| }); | ||
|
|
||
| let deprecatedCurrentUserPersonalDetails: OnyxEntry<OnyxTypes.PersonalDetails>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.PERSONAL_DETAILS_LIST, | ||
| callback: (value) => { | ||
| deprecatedCurrentUserPersonalDetails = value?.[userAccountID] ?? undefined; | ||
| deprecatedCurrentUserPersonalDetails = value?.[deprecatedUserAccountID] ?? undefined; | ||
| }, | ||
| }); | ||
|
|
||
| let allReportActions: OnyxCollection<OnyxTypes.ReportActions>; | ||
| Onyx.connect({ | ||
| key: ONYXKEYS.COLLECTION.REPORT_ACTIONS, | ||
| waitForCollectionCallback: true, | ||
| callback: (actions) => { | ||
|
|
@@ -1054,11 +1054,11 @@ | |
| } | ||
|
|
||
| function getCurrentUserEmail(): string { | ||
| return currentUserEmail; | ||
| return deprecatedCurrentUserEmail; | ||
| } | ||
|
|
||
| function getUserAccountID(): number { | ||
| return userAccountID; | ||
| return deprecatedUserAccountID; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1841,8 +1841,8 @@ | |
| reportActionID: testDriveIOUParams.iouOptimisticParams.action.reportActionID, | ||
| }); | ||
| // eslint-disable-next-line @typescript-eslint/no-deprecated | ||
| const text = Localize.translateLocal('testDrive.employeeInviteMessage', personalDetailsList?.[userAccountID]?.firstName ?? ''); | ||
| const textComment = buildOptimisticAddCommentReportAction({text, actorAccountID: userAccountID, reportActionID: testDriveIOUParams.testDriveCommentReportActionID}); | ||
| const text = Localize.translateLocal('testDrive.employeeInviteMessage', personalDetailsList?.[deprecatedUserAccountID]?.firstName ?? ''); | ||
| const textComment = buildOptimisticAddCommentReportAction({text, actorAccountID: deprecatedUserAccountID, reportActionID: testDriveIOUParams.testDriveCommentReportActionID}); | ||
| textComment.reportAction.created = DateUtils.subtractMillisecondsFromDateTime(testDriveIOUParams.iouOptimisticParams.createdAction.created, 1); | ||
|
|
||
| optimisticData.push( | ||
|
|
@@ -3079,6 +3079,7 @@ | |
| const cleanUpTransactionThreadReportOnyxData = getCleanUpTransactionThreadReportOnyxData({ | ||
| transactionThreadID, | ||
| shouldDeleteTransactionThread, | ||
| currentUserAccountID: deprecatedUserAccountID, | ||
| }); | ||
| optimisticData.push(...cleanUpTransactionThreadReportOnyxData.optimisticData); | ||
|
|
||
|
|
@@ -3272,7 +3273,7 @@ | |
| personalDetails, | ||
| betas, | ||
| } = moneyRequestInformation; | ||
| const {payeeAccountID = userAccountID, payeeEmail = currentUserEmail, participant} = participantParams; | ||
| const {payeeAccountID = deprecatedUserAccountID, payeeEmail = deprecatedCurrentUserEmail, participant} = participantParams; | ||
| const {policy, policyCategories, policyTagList, policyRecentlyUsedCategories, policyRecentlyUsedTags} = policyParams; | ||
| const { | ||
| attendees, | ||
|
|
@@ -3710,7 +3711,7 @@ | |
| betas, | ||
| isSelfTourViewed, | ||
| } = params; | ||
| const {payeeAccountID = userAccountID, payeeEmail = currentUserEmail, participant} = participantParams; | ||
| const {payeeAccountID = deprecatedUserAccountID, payeeEmail = deprecatedCurrentUserEmail, participant} = participantParams; | ||
| const {policy} = policyParams; | ||
| const { | ||
| comment, | ||
|
|
@@ -3756,7 +3757,7 @@ | |
| if (!chatReport) { | ||
| const currentTime = DateUtils.getDBTime(); | ||
| const selfDMReport = buildOptimisticSelfDMReport(currentTime); | ||
| const selfDMCreatedReportAction = buildOptimisticCreatedReportAction(currentUserEmail ?? '', currentTime); | ||
| const selfDMCreatedReportAction = buildOptimisticCreatedReportAction(deprecatedCurrentUserEmail ?? '', currentTime); | ||
| optimisticReportID = selfDMReport.reportID; | ||
| optimisticReportActionID = selfDMCreatedReportAction.reportActionID; | ||
| chatReport = selfDMReport; | ||
|
|
@@ -6013,7 +6014,7 @@ | |
| return; | ||
| } | ||
|
|
||
| const participantAccountIDs = getReportRecipientAccountIDs(iouReport, userAccountID); | ||
| const participantAccountIDs = getReportRecipientAccountIDs(iouReport, deprecatedUserAccountID); | ||
| const payerAccountID = participantAccountIDs.at(0); | ||
|
|
||
| if (!payerAccountID) { | ||
|
|
@@ -6069,8 +6070,8 @@ | |
| } | ||
|
|
||
| const participantParams = { | ||
| payeeAccountID: userAccountID, | ||
| payeeEmail: currentUserEmail, | ||
| payeeAccountID: deprecatedUserAccountID, | ||
| payeeEmail: deprecatedCurrentUserEmail, | ||
| participant: { | ||
| accountID: payerAccountID, | ||
| login: payerEmail, | ||
|
|
@@ -6221,7 +6222,7 @@ | |
| // If a draft policy was used, then the CategorizeTrackedExpense command will create a real one | ||
| // so let's track that conversion here | ||
| if (isDraftPolicy) { | ||
| GoogleTagManager.publishEvent(CONST.ANALYTICS.EVENT.WORKSPACE_CREATED, userAccountID); | ||
| GoogleTagManager.publishEvent(CONST.ANALYTICS.EVENT.WORKSPACE_CREATED, deprecatedUserAccountID); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -7562,7 +7563,7 @@ | |
| personalDetailListAction: oneOnOnePersonalDetailListAction, | ||
| }, | ||
| currentUserAccountIDParam: currentUserAccountID, | ||
| currentUserEmailParam: currentUserEmail, | ||
| currentUserEmailParam: deprecatedCurrentUserEmail, | ||
| hasViolations, | ||
| quickAction, | ||
| personalDetails, | ||
|
|
@@ -7776,8 +7777,8 @@ | |
| moneyRequestReportID, | ||
| participantParams: { | ||
| participant, | ||
| payeeAccountID: userAccountID, | ||
| payeeEmail: currentUserEmail, | ||
| payeeAccountID: deprecatedUserAccountID, | ||
| payeeEmail: deprecatedCurrentUserEmail, | ||
| }, | ||
| policyParams: { | ||
| policy, | ||
|
|
@@ -8453,13 +8454,15 @@ | |
| isChatIOUReportArchived, | ||
| updatedReportPreviewAction, | ||
| shouldAddUpdatedReportPreviewActionToOnyxData = true, | ||
| currentUserAccountID, | ||
| }: { | ||
| transactionThreadID?: string; | ||
| shouldDeleteTransactionThread: boolean; | ||
| reportAction?: ReportAction; | ||
| isChatIOUReportArchived?: boolean; | ||
| updatedReportPreviewAction?: ReportAction; | ||
| shouldAddUpdatedReportPreviewActionToOnyxData?: boolean; | ||
| currentUserAccountID: number; | ||
| }) { | ||
| const optimisticData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS>> = []; | ||
| const successData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT | typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS>> = []; | ||
|
|
@@ -8484,7 +8487,7 @@ | |
| stateNum: CONST.REPORT.STATE_NUM.APPROVED, | ||
| statusNum: CONST.REPORT.STATUS_NUM.CLOSED, | ||
| participants: { | ||
| [userAccountID]: { | ||
| [currentUserAccountID]: { | ||
| notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN, | ||
| }, | ||
| }, | ||
|
|
@@ -8695,7 +8698,14 @@ | |
| onyxMethod: Onyx.METHOD.MERGE, | ||
| key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport?.reportID}`, | ||
| value: { | ||
| hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, updatedIOUReport, currentUserEmail, currentUserAccountID, allTransactionViolationsParam, undefined), | ||
| hasOutstandingChildRequest: hasOutstandingChildRequest( | ||
| chatReport, | ||
| updatedIOUReport, | ||
| deprecatedCurrentUserEmail, | ||
| currentUserAccountID, | ||
| allTransactionViolationsParam, | ||
| undefined, | ||
| ), | ||
| }, | ||
| }); | ||
| } | ||
|
|
@@ -8714,7 +8724,14 @@ | |
| onyxMethod: Onyx.METHOD.MERGE, | ||
| key: `${ONYXKEYS.COLLECTION.REPORT}${chatReport?.reportID}`, | ||
| value: { | ||
| hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, iouReport?.reportID, currentUserEmail, currentUserAccountID, allTransactionViolationsParam, undefined), | ||
| hasOutstandingChildRequest: hasOutstandingChildRequest( | ||
| chatReport, | ||
| iouReport?.reportID, | ||
| deprecatedCurrentUserEmail, | ||
| currentUserAccountID, | ||
| allTransactionViolationsParam, | ||
| undefined, | ||
| ), | ||
| iouReportID: null, | ||
| ...optimisticLastReportData, | ||
| }, | ||
|
|
@@ -8732,7 +8749,13 @@ | |
| }); | ||
| } | ||
|
|
||
| const cleanUpTransactionThreadReportOnyxData = getCleanUpTransactionThreadReportOnyxData({shouldDeleteTransactionThread, transactionThreadID, reportAction, isChatIOUReportArchived}); | ||
| const cleanUpTransactionThreadReportOnyxData = getCleanUpTransactionThreadReportOnyxData({ | ||
| shouldDeleteTransactionThread, | ||
| transactionThreadID, | ||
| reportAction, | ||
| isChatIOUReportArchived, | ||
| currentUserAccountID, | ||
| }); | ||
| optimisticData.push(...cleanUpTransactionThreadReportOnyxData.optimisticData); | ||
|
|
||
| const successData: Array<OnyxUpdate<typeof ONYXKEYS.COLLECTION.REPORT_ACTIONS | typeof ONYXKEYS.COLLECTION.REPORT | typeof ONYXKEYS.COLLECTION.TRANSACTION>> = [ | ||
|
|
@@ -9445,7 +9468,7 @@ | |
| successData: policySuccessData, | ||
| params, | ||
| } = buildPolicyData({ | ||
| policyOwnerEmail: currentUserEmail, | ||
| policyOwnerEmail: deprecatedCurrentUserEmail, | ||
| makeMeAdmin: true, | ||
| policyID: payerPolicyID, | ||
| currentUserAccountIDParam: currentUserAccountIDParam ?? CONST.DEFAULT_NUMBER_ID, | ||
|
|
@@ -9519,7 +9542,7 @@ | |
| const optimisticChatReport = { | ||
| ...chatReport, | ||
| lastReadTime: DateUtils.getDBTime(), | ||
| hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, iouReport?.reportID, currentUserEmail, currentUserAccountIDParam, allTransactionViolations, undefined), | ||
| hasOutstandingChildRequest: hasOutstandingChildRequest(chatReport, iouReport?.reportID, deprecatedCurrentUserEmail, currentUserAccountIDParam, allTransactionViolations, undefined), | ||
|
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. Naming Consistency: Consider standardizing on
Member
Author
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. Not in the scope of this project. Will update later.
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. Yeah, I agree with the suggestion too. I'm fine if you update it in later PRs. |
||
| iouReportID: null, | ||
| lastMessageText: getReportActionText(optimisticIOUReportAction), | ||
| lastMessageHtml: getReportActionHtml(optimisticIOUReportAction), | ||
|
|
@@ -9767,7 +9790,7 @@ | |
| } | ||
|
|
||
| const managerID = iouReport?.managerID ?? CONST.DEFAULT_NUMBER_ID; | ||
| const isCurrentUserManager = managerID === userAccountID; | ||
| const isCurrentUserManager = managerID === deprecatedUserAccountID; | ||
| const isOpenExpenseReport = isOpenExpenseReportReportUtils(iouReport); | ||
| const isApproved = isReportApproved({report: iouReport}); | ||
| const iouSettled = isSettled(iouReport); | ||
|
|
@@ -9827,12 +9850,12 @@ | |
| return false; | ||
| } | ||
| if (chatReport?.invoiceReceiver?.type === CONST.REPORT.INVOICE_RECEIVER_TYPE.INDIVIDUAL) { | ||
| return chatReport?.invoiceReceiver?.accountID === userAccountID; | ||
| return chatReport?.invoiceReceiver?.accountID === deprecatedUserAccountID; | ||
| } | ||
| return invoiceReceiverPolicy?.role === CONST.POLICY.ROLE.ADMIN; | ||
| } | ||
|
|
||
| const isPayer = isPayerReportUtils(userAccountID, currentUserEmail, iouReport, bankAccountList, policy, onlyShowPayElsewhere); | ||
| const isPayer = isPayerReportUtils(deprecatedUserAccountID, deprecatedCurrentUserEmail, iouReport, bankAccountList, policy, onlyShowPayElsewhere); | ||
|
|
||
| const {reimbursableSpend} = getMoneyRequestSpendBreakdown(iouReport); | ||
| const isAutoReimbursable = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES ? false : canBeAutoReimbursed(iouReport, policy); | ||
|
|
@@ -9926,8 +9949,8 @@ | |
| policy, | ||
| getReportTransactions(iouReport?.reportID), | ||
| allTransactionViolations, | ||
| currentUserEmail, | ||
| userAccountID, | ||
| deprecatedCurrentUserEmail, | ||
| deprecatedUserAccountID, | ||
| getAllReportActions(iouReport?.reportID), | ||
| ); | ||
| if (isWaitingSubmitFromCurrentUser) { | ||
|
|
@@ -11355,7 +11378,7 @@ | |
| return; | ||
| } | ||
|
|
||
| const personalDetailsListValues = Object.values(getPersonalDetailsForAccountIDs(userAccountID ? [userAccountID] : [], personalDetailsList)); | ||
| const personalDetailsListValues = Object.values(getPersonalDetailsForAccountIDs(deprecatedUserAccountID ? [deprecatedUserAccountID] : [], personalDetailsList)); | ||
| const personalDetails = personalDetailsListValues.at(0); | ||
|
|
||
| let onboardingPurpose = introSelected?.choice; | ||
|
|
@@ -11982,7 +12005,7 @@ | |
| return false; | ||
| } | ||
|
|
||
| const suggestedSearches = getSuggestedSearches(userAccountID); | ||
| const suggestedSearches = getSuggestedSearches(deprecatedUserAccountID); | ||
| const submitQueryJSON = suggestedSearches[CONST.SEARCH.SEARCH_KEYS.SUBMIT].searchQueryJSON; | ||
| const approveQueryJSON = suggestedSearches[CONST.SEARCH.SEARCH_KEYS.APPROVE].searchQueryJSON; | ||
| const unapprovedCashSimilarSearchHash = suggestedSearches[CONST.SEARCH.SEARCH_KEYS.UNAPPROVED_CASH].similarSearchHash; | ||
|
|
@@ -12504,7 +12527,7 @@ | |
| amount: transactionAmount, | ||
| currency: getCurrency(transaction), | ||
| comment, | ||
| payeeEmail: currentUserEmail, | ||
| payeeEmail: deprecatedCurrentUserEmail, | ||
| participants: [{accountID: report?.ownerAccountID}], | ||
| transactionID: transaction.transactionID, | ||
| existingTransactionThreadReportID: childReportID, | ||
|
|
@@ -12766,7 +12789,7 @@ | |
| const shouldHaveOutstandingChildRequest = hasOutstandingChildRequest( | ||
| policyExpenseChat, | ||
| excludedReportID, | ||
| currentUserEmail, | ||
| deprecatedCurrentUserEmail, | ||
| currentUserAccountIDParam, | ||
| allTransactionViolations, | ||
| undefined, | ||
|
|
@@ -12826,7 +12849,7 @@ | |
| type: CONST.VIOLATION_TYPES.WARNING, | ||
| data: { | ||
| comment: comment ?? '', | ||
| rejectedBy: currentUserEmail, | ||
| rejectedBy: deprecatedCurrentUserEmail, | ||
| rejectedDate: DateUtils.getDBTime(), | ||
| }, | ||
| showInReview: true, | ||
|
|
@@ -13337,7 +13360,15 @@ | |
| // bulk-edit comments are visible immediately while still offline. | ||
| let didCreateThreadInThisIteration = false; | ||
| if (!transactionThreadReportID && iouReport?.reportID) { | ||
| const optimisticTransactionThread = createTransactionThreadReport(introSelected, currentUserEmail, userAccountID, betas, iouReport, reportAction, transaction); | ||
| const optimisticTransactionThread = createTransactionThreadReport( | ||
| introSelected, | ||
| deprecatedCurrentUserEmail, | ||
| deprecatedUserAccountID, | ||
| betas, | ||
| iouReport, | ||
| reportAction, | ||
| transaction, | ||
| ); | ||
| if (optimisticTransactionThread?.reportID) { | ||
| transactionThreadReportID = optimisticTransactionThread.reportID; | ||
| transactionThread = optimisticTransactionThread; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in later PRs...