Skip to content

Commit e4ce560

Browse files
committed
Refactor rejectMoneyRequest
1 parent 894329d commit e4ce560

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/libs/actions/IOU/RejectMoneyRequest.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import ROUTES from '@src/ROUTES';
4141
import SCREENS from '@src/SCREENS';
4242
import type * as OnyxTypes from '@src/types/onyx';
4343
import {isEmptyObject} from '@src/types/utils/EmptyObject';
44-
import {getAllReports, getAllTransactions, getAllTransactionViolations, getCurrentUserEmail} from '.';
44+
import {getAllReports, getAllTransactions, getAllTransactionViolations} from '.';
4545

4646
type RejectMoneyRequestData = {
4747
optimisticData: Array<
@@ -105,14 +105,14 @@ function prepareRejectMoneyRequestData(
105105
comment: string,
106106
policy: OnyxEntry<OnyxTypes.Policy>,
107107
currentUserAccountIDParam: number,
108+
currentUserLogin: string,
108109
betas: OnyxEntry<OnyxTypes.Beta[]>,
109110
options?: {sharedRejectedToReportID?: string},
110111
shouldUseBulkAction?: boolean,
111112
): RejectMoneyRequestData | undefined {
112113
const allTransactions = getAllTransactions();
113114
const allReports = getAllReports();
114115
const allTransactionViolations = getAllTransactionViolations();
115-
const deprecatedCurrentUserEmail = getCurrentUserEmail();
116116

117117
const transaction = allTransactions[`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`];
118118
const transactionAmount = getAmount(transaction);
@@ -456,7 +456,7 @@ function prepareRejectMoneyRequestData(
456456
amount: transactionAmount,
457457
currency: getCurrency(transaction),
458458
comment: parsedComment,
459-
payeeEmail: deprecatedCurrentUserEmail,
459+
payeeEmail: currentUserLogin,
460460
participants: [{accountID: report?.ownerAccountID}],
461461
transactionID: transaction.transactionID,
462462
existingTransactionThreadReportID: childReportID,
@@ -717,7 +717,7 @@ function prepareRejectMoneyRequestData(
717717
const shouldHaveOutstandingChildRequest = hasOutstandingChildRequest(
718718
policyExpenseChat,
719719
excludedReportID,
720-
deprecatedCurrentUserEmail,
720+
currentUserLogin,
721721
currentUserAccountIDParam,
722722
allTransactionViolations,
723723
undefined,
@@ -777,7 +777,7 @@ function prepareRejectMoneyRequestData(
777777
type: CONST.VIOLATION_TYPES.WARNING,
778778
data: {
779779
comment: comment ?? '',
780-
rejectedBy: deprecatedCurrentUserEmail,
780+
rejectedBy: currentUserLogin,
781781
rejectedDate: DateUtils.getDBTime(),
782782
},
783783
showInReview: true,
@@ -874,10 +874,11 @@ function rejectMoneyRequest(
874874
comment: string,
875875
policy: OnyxEntry<OnyxTypes.Policy>,
876876
currentUserAccountIDParam: number,
877+
currentUserLogin: string,
877878
betas: OnyxEntry<OnyxTypes.Beta[]>,
878879
options?: {sharedRejectedToReportID?: string},
879880
): Route | undefined {
880-
const data = prepareRejectMoneyRequestData(transactionID, reportID, comment, policy, currentUserAccountIDParam, betas, options);
881+
const data = prepareRejectMoneyRequestData(transactionID, reportID, comment, policy, currentUserAccountIDParam, currentUserLogin, betas, options);
881882
if (!data) {
882883
return;
883884
}

0 commit comments

Comments
 (0)