Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/hooks/useDeleteTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ function useDeleteTransactions({report, reportActions, policy}: UseDeleteTransac
selectedTransactionIDs: transactionIDs,
allTransactionViolationsParam: transactionViolations,
currentUserAccountID: currentUserPersonalDetails.accountID,
currentUserEmail: currentUserPersonalDetails.email ?? '',
});
deletedTransactionIDs.push(transactionID);
if (action.childReportID) {
Expand Down
2 changes: 2 additions & 0 deletions src/libs/actions/IOU/Duplicate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ function mergeDuplicates({transactionThreadReportID: optimisticTransactionThread
const allTransactionViolations = getAllTransactionViolations();
const allReports = getAllReports();
const currentUserEmail = getCurrentUserEmail();
const currentUserAccountID = getUserAccountID();

const originalSelectedTransaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${params.transactionID}`];

Expand Down Expand Up @@ -221,6 +222,7 @@ function mergeDuplicates({transactionThreadReportID: optimisticTransactionThread
reportAction: iouAction,
updatedReportPreviewAction,
shouldAddUpdatedReportPreviewActionToOnyxData: Number(index) === iouActionsToDelete.length - 1,
currentUserAccountID,
});
cleanUpTransactionThreadReportsOptimisticData.push(...cleanUpTransactionThreadReportOnyxDataForIouAction.optimisticData);
cleanUpTransactionThreadReportsSuccessData.push(...cleanUpTransactionThreadReportOnyxDataForIouAction.successData);
Expand Down
80 changes: 47 additions & 33 deletions src/libs/actions/IOU/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@
import type {Comment, Receipt, ReceiptSource, Routes, SplitShares, TransactionChanges, TransactionCustomUnit, WaypointCollection} from '@src/types/onyx/Transaction';
import type {FileObject} from '@src/types/utils/Attachment';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import {resolveDetachReceiptConflicts} from '../RequestConflictUtils';

Check warning on line 265 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Unexpected parent import '../RequestConflictUtils'. Use '@userActions/RequestConflictUtils' instead

type IOURequestType = ValueOf<typeof CONST.IOU.REQUEST_TYPE>;

Expand Down Expand Up @@ -782,7 +782,7 @@
};

let allPersonalDetails: OnyxTypes.PersonalDetailsList = {};
Onyx.connect({

Check warning on line 785 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
allPersonalDetails = value ?? {};
Expand Down Expand Up @@ -847,6 +847,7 @@
isChatIOUReportArchived: boolean | undefined;
allTransactionViolationsParam: OnyxCollection<OnyxTypes.TransactionViolations>;
currentUserAccountID: number;
currentUserEmail: string;
};

type DeleteMoneyRequestFunctionParams = {
Expand All @@ -862,6 +863,7 @@
selectedTransactionIDs?: string[];
allTransactionViolationsParam: OnyxCollection<OnyxTypes.TransactionViolations>;
currentUserAccountID: number;
currentUserEmail: string;
};

type PayMoneyRequestFunctionParams = {
Expand Down Expand Up @@ -915,7 +917,7 @@
};

let allTransactions: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 920 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -929,7 +931,7 @@
});

let allTransactionDrafts: NonNullable<OnyxCollection<OnyxTypes.Transaction>> = {};
Onyx.connect({

Check warning on line 934 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_DRAFT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -938,7 +940,7 @@
});

let allTransactionViolations: NonNullable<OnyxCollection<OnyxTypes.TransactionViolations>> = {};
Onyx.connect({

Check warning on line 943 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -952,7 +954,7 @@
});

let allPolicyTags: OnyxCollection<OnyxTypes.PolicyTagLists> = {};
Onyx.connect({

Check warning on line 957 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY_TAGS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -965,7 +967,7 @@
});

let allReports: OnyxCollection<OnyxTypes.Report>;
Onyx.connect({

Check warning on line 970 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -974,7 +976,7 @@
});

let allReportNameValuePairs: OnyxCollection<OnyxTypes.ReportNameValuePairs>;
Onyx.connect({

Check warning on line 979 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -982,21 +984,21 @@
},
});

let userAccountID = -1;
let currentUserEmail = '';
let deprecatedUserAccountID = -1;
let deprecatedCurrentUserEmail = '';
Onyx.connect({

Check warning on line 989 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
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({

Check warning on line 998 in src/libs/actions/IOU/index.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
deprecatedCurrentUserPersonalDetails = value?.[userAccountID] ?? undefined;
deprecatedCurrentUserPersonalDetails = value?.[deprecatedUserAccountID] ?? undefined;
},
});

Expand Down Expand Up @@ -1046,11 +1048,11 @@
}

function getCurrentUserEmail(): string {
return currentUserEmail;
return deprecatedCurrentUserEmail;
}

function getUserAccountID(): number {
return userAccountID;
return deprecatedUserAccountID;
}

/**
Expand Down Expand Up @@ -1834,8 +1836,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(
Expand Down Expand Up @@ -3072,6 +3074,7 @@
const cleanUpTransactionThreadReportOnyxData = getCleanUpTransactionThreadReportOnyxData({
transactionThreadID,
shouldDeleteTransactionThread,
currentUserAccountID: deprecatedUserAccountID,
});
optimisticData.push(...cleanUpTransactionThreadReportOnyxData.optimisticData);

Expand Down Expand Up @@ -3245,7 +3248,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,
Expand Down Expand Up @@ -3680,7 +3683,7 @@
betas,
isSelfTourViewed,
} = params;
const {payeeAccountID = userAccountID, payeeEmail = currentUserEmail, participant} = participantParams;
const {payeeAccountID = deprecatedUserAccountID, payeeEmail = deprecatedCurrentUserEmail, participant} = participantParams;
const {policy} = policyParams;
const {
comment,
Expand Down Expand Up @@ -3726,7 +3729,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;
Expand Down Expand Up @@ -5973,7 +5976,7 @@
return;
}

const participantAccountIDs = getReportRecipientAccountIDs(iouReport, userAccountID);
const participantAccountIDs = getReportRecipientAccountIDs(iouReport, deprecatedUserAccountID);
const payerAccountID = participantAccountIDs.at(0);

if (!payerAccountID) {
Expand Down Expand Up @@ -6029,8 +6032,8 @@
}

const participantParams = {
payeeAccountID: userAccountID,
payeeEmail: currentUserEmail,
payeeAccountID: deprecatedUserAccountID,
payeeEmail: deprecatedCurrentUserEmail,
participant: {
accountID: payerAccountID,
login: payerEmail,
Expand Down Expand Up @@ -6181,7 +6184,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);
}
}

Expand Down Expand Up @@ -7522,7 +7525,7 @@
personalDetailListAction: oneOnOnePersonalDetailListAction,
},
currentUserAccountIDParam: currentUserAccountID,
currentUserEmailParam: currentUserEmail,
currentUserEmailParam: deprecatedCurrentUserEmail,
hasViolations,
quickAction,
personalDetails,
Expand Down Expand Up @@ -7736,8 +7739,8 @@
moneyRequestReportID,
participantParams: {
participant,
payeeAccountID: userAccountID,
payeeEmail: currentUserEmail,
payeeAccountID: deprecatedUserAccountID,
payeeEmail: deprecatedCurrentUserEmail,
},
policyParams: {
policy,
Expand Down Expand Up @@ -8413,13 +8416,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>> = [];
Expand All @@ -8444,7 +8449,7 @@
stateNum: CONST.REPORT.STATE_NUM.APPROVED,
statusNum: CONST.REPORT.STATUS_NUM.CLOSED,
participants: {
[userAccountID]: {
[currentUserAccountID]: {
notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN,
},
},
Expand Down Expand Up @@ -8566,6 +8571,7 @@
selectedTransactionIDs,
allTransactionViolationsParam,
currentUserAccountID,
currentUserEmail,
}: DeleteMoneyRequestFunctionParams) {
if (!transactionID) {
return;
Expand Down Expand Up @@ -8686,7 +8692,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>> = [
Expand Down Expand Up @@ -8845,6 +8857,7 @@
isChatIOUReportArchived,
allTransactionViolationsParam,
currentUserAccountID,
currentUserEmail,
}: DeleteTrackExpenseParams) {
if (!chatReportID || !transactionID) {
return;
Expand Down Expand Up @@ -8874,6 +8887,7 @@
isSingleTransactionView,
allTransactionViolationsParam,
currentUserAccountID,
currentUserEmail,
});
return urlToNavigateBack;
}
Expand Down Expand Up @@ -9399,7 +9413,7 @@
successData: policySuccessData,
params,
} = buildPolicyData({
policyOwnerEmail: currentUserEmail,
policyOwnerEmail: deprecatedCurrentUserEmail,
makeMeAdmin: true,
policyID: payerPolicyID,
currentUserAccountIDParam: currentUserAccountIDParam ?? CONST.DEFAULT_NUMBER_ID,
Expand Down Expand Up @@ -9473,7 +9487,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),
iouReportID: null,
lastMessageText: getReportActionText(optimisticIOUReportAction),
lastMessageHtml: getReportActionHtml(optimisticIOUReportAction),
Expand Down Expand Up @@ -9721,7 +9735,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);
Expand Down Expand Up @@ -9781,12 +9795,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);
Expand Down Expand Up @@ -9880,8 +9894,8 @@
policy,
getReportTransactions(iouReport?.reportID),
allTransactionViolations,
currentUserEmail,
userAccountID,
deprecatedCurrentUserEmail,
deprecatedUserAccountID,
getAllReportActions(iouReport?.reportID),
);
if (isWaitingSubmitFromCurrentUser) {
Expand Down Expand Up @@ -11309,7 +11323,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;
Expand Down Expand Up @@ -11936,7 +11950,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;
Expand Down Expand Up @@ -12458,7 +12472,7 @@
amount: transactionAmount,
currency: getCurrency(transaction),
comment,
payeeEmail: currentUserEmail,
payeeEmail: deprecatedCurrentUserEmail,
participants: [{accountID: report?.ownerAccountID}],
transactionID: transaction.transactionID,
existingTransactionThreadReportID: childReportID,
Expand Down Expand Up @@ -12720,7 +12734,7 @@
const shouldHaveOutstandingChildRequest = hasOutstandingChildRequest(
policyExpenseChat,
excludedReportID,
currentUserEmail,
deprecatedCurrentUserEmail,
currentUserAccountIDParam,
allTransactionViolations,
undefined,
Expand Down Expand Up @@ -12780,7 +12794,7 @@
type: CONST.VIOLATION_TYPES.WARNING,
data: {
comment: comment ?? '',
rejectedBy: currentUserEmail,
rejectedBy: deprecatedCurrentUserEmail,
rejectedDate: DateUtils.getDBTime(),
},
showInReview: true,
Expand Down
1 change: 1 addition & 0 deletions src/libs/actions/MergeTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ function mergeTransactionRequest({
transactionThreadID: sourceTransactionThreadReportID,
shouldDeleteTransactionThread,
reportAction: sourceIouAction,
currentUserAccountID: currentUserAccountIDParam,
});
optimisticSourceReportActionData.push(...cleanUpSourceTransactionThreadReportOnyxData.optimisticData);
successSourceReportActionData.push(...cleanUpSourceTransactionThreadReportOnyxData.successData);
Expand Down
1 change: 1 addition & 0 deletions src/libs/actions/Search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,7 @@ function bulkDeleteReports({
selectedTransactionIDs: batchTransactionIDsForReport.length > 0 ? batchTransactionIDsForReport : undefined,
allTransactionViolationsParam: transactionsViolations,
currentUserAccountID: currentUserAccountIDParam,
currentUserEmail: currentUserEmailParam,
});
}

Expand Down
1 change: 1 addition & 0 deletions src/pages/ReportDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,7 @@ function ReportDetailsPage({policy, report, route, reportMetadata}: ReportDetail
isChatIOUReportArchived,
allTransactionViolationsParam: allTransactionViolations,
currentUserAccountID: currentUserPersonalDetails.accountID,
currentUserEmail: currentUserPersonalDetails.email ?? '',
});
} else if (iouTransactionID) {
deleteTransactions([iouTransactionID], duplicateTransactions, duplicateTransactionViolations, currentSearchHash, isSingleTransactionView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ function PopoverReportActionContextMenu({ref}: PopoverReportActionContextMenuPro
isChatIOUReportArchived,
allTransactionViolationsParam: allTransactionViolations,
currentUserAccountID,
currentUserEmail: email ?? '',
});
} else if (originalMessage?.IOUTransactionID) {
deleteTransactions([originalMessage.IOUTransactionID], duplicateTransactions, duplicateTransactionViolations, currentSearchHash);
Expand Down
Loading
Loading