Skip to content

Commit

Permalink
eslint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
FitseTLT committed Dec 24, 2024
1 parent e755386 commit 6569a7d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,20 @@ function MoneyRequestPreviewContent({
const route = useRoute<PlatformStackRouteProp<TransactionDuplicateNavigatorParamList, typeof SCREENS.TRANSACTION_DUPLICATE.REVIEW>>();
const {shouldUseNarrowLayout} = useResponsiveLayout();
const [personalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${chatReportID || '-1'}`);
const [chatReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${chatReportID || undefined}`);
const [session] = useOnyx(ONYXKEYS.SESSION);
const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${iouReportID || '-1'}`);
const [iouReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${iouReportID || undefined}`);

const policy = PolicyUtils.getPolicy(iouReport?.policyID);
const isMoneyRequestAction = ReportActionsUtils.isMoneyRequestAction(action);
const transactionID = isMoneyRequestAction ? ReportActionsUtils.getOriginalMessage(action)?.IOUTransactionID : '-1';
const transactionID = isMoneyRequestAction ? ReportActionsUtils.getOriginalMessage(action)?.IOUTransactionID : undefined;
const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${transactionID}`);
const [walletTerms] = useOnyx(ONYXKEYS.WALLET_TERMS);
const [transactionViolations] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS);

const sessionAccountID = session?.accountID;
const managerID = iouReport?.managerID ?? -1;
const ownerAccountID = iouReport?.ownerAccountID ?? -1;
const managerID = iouReport?.managerID ?? CONST.DEFAULT_NUMBER_ID;
const ownerAccountID = iouReport?.ownerAccountID ?? CONST.DEFAULT_NUMBER_ID;
const isPolicyExpenseChat = ReportUtils.isPolicyExpenseChat(chatReport);

const participantAccountIDs =
Expand Down Expand Up @@ -117,12 +117,12 @@ function MoneyRequestPreviewContent({
const isOnHold = TransactionUtils.isOnHold(transaction);
const isSettlementOrApprovalPartial = !!iouReport?.pendingFields?.partial;
const isPartialHold = isSettlementOrApprovalPartial && isOnHold;
const hasViolations = TransactionUtils.shouldShowViolation({transactionID: transaction?.transactionID ?? '-1', transactionViolations, showInReview: true, parentReportAction: action});
const hasViolations = TransactionUtils.shouldShowViolation({transactionID: transaction?.transactionID, transactionViolations, showInReview: true, parentReportAction: action});
const hasNoticeTypeViolations =
TransactionUtils.shouldShowNoticeTypeViolation({transactionID: transaction?.transactionID ?? '-1', transactionViolations, showInReview: true, parentReportAction: action}) &&
TransactionUtils.shouldShowNoticeTypeViolation({transactionID: transaction?.transactionID, transactionViolations, showInReview: true, parentReportAction: action}) &&
ReportUtils.isPaidGroupPolicy(iouReport);
const hasWarningTypeViolations = TransactionUtils.shouldShowWarningTypeViolation({
transactionID: transaction?.transactionID ?? '-1',
transactionID: transaction?.transactionID,
transactionViolations,
showInReview: true,
parentReportAction: action,
Expand Down Expand Up @@ -163,7 +163,7 @@ function MoneyRequestPreviewContent({

const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${route.params?.threadReportID}`);
const parentReportAction = ReportActionsUtils.getReportAction(report?.parentReportID ?? '', report?.parentReportActionID ?? '');

Check failure on line 165 in src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Check failure on line 165 in src/components/ReportActionItem/MoneyRequestPreview/MoneyRequestPreviewContent.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

const reviewingTransactionID = ReportActionsUtils.isMoneyRequestAction(parentReportAction) ? ReportActionsUtils.getOriginalMessage(parentReportAction)?.IOUTransactionID ?? '-1' : '-1';
const reviewingTransactionID = ReportActionsUtils.isMoneyRequestAction(parentReportAction) ? ReportActionsUtils.getOriginalMessage(parentReportAction)?.IOUTransactionID : undefined;

/*
Show the merchant for IOUs and expenses only if:
Expand Down Expand Up @@ -260,10 +260,10 @@ function MoneyRequestPreviewContent({
if (TransactionUtils.isPending(transaction)) {
return {shouldShow: true, messageIcon: Expensicons.CreditCardHourglass, messageDescription: translate('iou.transactionPending')};
}
if (TransactionUtils.shouldShowBrokenConnectionViolation(transaction?.transactionID ?? '-1', iouReport, policy)) {
if (TransactionUtils.shouldShowBrokenConnectionViolation(transaction?.transactionID, iouReport, policy)) {
return {shouldShow: true, messageIcon: Expensicons.Hourglass, messageDescription: translate('violations.brokenConnection530Error')};
}
if (TransactionUtils.hasPendingUI(transaction, TransactionUtils.getTransactionViolations(transaction?.transactionID ?? '-1', transactionViolations))) {
if (TransactionUtils.hasPendingUI(transaction, TransactionUtils.getTransactionViolations(transaction?.transactionID, transactionViolations))) {
return {shouldShow: true, messageIcon: Expensicons.Hourglass, messageDescription: translate('iou.pendingMatchWithCreditCard')};
}
return {shouldShow: false};
Expand Down
16 changes: 8 additions & 8 deletions src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ function shouldShowMissingSmartscanFieldsError(transaction: OnyxInputOrEntry<Tra
/**
* Get all transaction violations of the transaction with given tranactionID.
*/
function getTransactionViolations(transactionID: string, transactionViolations: OnyxCollection<TransactionViolations> | null): TransactionViolations | null {
function getTransactionViolations(transactionID: string | undefined, transactionViolations: OnyxCollection<TransactionViolations> | null): TransactionViolations | null {
return transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID] ?? null;
}

Expand All @@ -748,7 +748,7 @@ function hasPendingRTERViolation(transactionViolations?: TransactionViolations |
/**
* Check if there is broken connection violation.
*/
function hasBrokenConnectionViolation(transactionID: string): boolean {
function hasBrokenConnectionViolation(transactionID: string | undefined): boolean {
const violations = getTransactionViolations(transactionID, allTransactionViolations);
return !!violations?.find(
(violation) =>
Expand All @@ -760,7 +760,7 @@ function hasBrokenConnectionViolation(transactionID: string): boolean {
/**
* Check if user should see broken connection violation warning.
*/
function shouldShowBrokenConnectionViolation(transactionID: string, report: OnyxEntry<Report> | SearchReport, policy: OnyxEntry<Policy> | SearchPolicy): boolean {
function shouldShowBrokenConnectionViolation(transactionID: string | undefined, report: OnyxEntry<Report> | SearchReport, policy: OnyxEntry<Policy> | SearchPolicy): boolean {
return (
hasBrokenConnectionViolation(transactionID) &&
(!PolicyUtils.isPolicyAdmin(policy) || ReportUtils.isOpenExpenseReport(report) || (ReportUtils.isProcessingReport(report) && PolicyUtils.isInstantSubmitEnabled(policy)))
Expand Down Expand Up @@ -913,7 +913,7 @@ function shouldShowViolation({
showInReview,
parentReportAction,
}: {
transactionID: string;
transactionID: string | undefined;
transactionViolations: OnyxCollection<TransactionViolations>;
showInReview?: boolean;
parentReportAction: OnyxEntry<ReportAction>;
Expand All @@ -933,9 +933,9 @@ function shouldShowViolation({
* true because we use this function to show RBR only for the user side who can edit the transaction
* but if we can't determine they cannot edit it, we opted to show the RBR instead of hiding it.
*/
function canEditTransaction(transactionID: string, parentReportAction: OnyxEntry<ReportAction>): boolean {
function canEditTransaction(transactionID: string | undefined, parentReportAction: OnyxEntry<ReportAction>): boolean {
const report = allReports?.[`${ONYXKEYS.COLLECTION.REPORT}${parentReportAction?.childReportID ?? CONST.DEFAULT_NUMBER_ID}`];
const transaction = getTransaction(transactionID ?? '-1');
const transaction = getTransaction(transactionID);
if (report && transaction && parentReportAction) {
const canUserPerformWriteAction = !!ReportUtils.canUserPerformWriteAction(report);
const canEditRequest = canUserPerformWriteAction && ReportActionsUtils.isMoneyRequestAction(parentReportAction) && ReportUtils.canEditMoneyRequest(parentReportAction, transaction);
Expand All @@ -955,7 +955,7 @@ function shouldShowNoticeTypeViolation({
showInReview,
parentReportAction,
}: {
transactionID: string;
transactionID: string | undefined;
transactionViolations: OnyxCollection<TransactionViolations>;
showInReview?: boolean;
parentReportAction: OnyxEntry<ReportAction>;
Expand All @@ -979,7 +979,7 @@ function shouldShowWarningTypeViolation({
showInReview,
parentReportAction,
}: {
transactionID: string;
transactionID: string | undefined;
transactionViolations: OnyxCollection<TransactionViolations>;
showInReview?: boolean;
parentReportAction: OnyxEntry<ReportAction>;
Expand Down

0 comments on commit 6569a7d

Please sign in to comment.