Skip to content

Commit

Permalink
Revert "Merge pull request #53176 from abzokhattab/avoid-hiding-pay-b…
Browse files Browse the repository at this point in the history
…utton-when-violations-are-held"

This reverts commit 9014956, reversing
changes made to 238add9.
  • Loading branch information
mountiny committed Nov 27, 2024
1 parent 0bde27e commit 3f9bf24
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 27 deletions.
9 changes: 0 additions & 9 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6362,14 +6362,6 @@ function hasViolations(reportID: string, transactionViolations: OnyxCollection<T
return transactions.some((transaction) => TransactionUtils.hasViolation(transaction.transactionID, transactionViolations, shouldShowInReview));
}

/**
* Checks to see if a report contains non-hold violations
*/
function hasNonHoldViolation(reportID: string, transactionViolations: OnyxCollection<TransactionViolation[]>, shouldShowInReview?: boolean): boolean {
const transactions = reportsTransactions[reportID] ?? [];
return transactions.some((transaction) => TransactionUtils.hasNonHoldViolation(transaction.transactionID, transactionViolations, shouldShowInReview));
}

/**
* Checks to see if a report contains a violation of type `warning`
*/
Expand Down Expand Up @@ -8629,7 +8621,6 @@ export {
hasSmartscanError,
hasUpdatedTotal,
hasViolations,
hasNonHoldViolation,
hasWarningTypeViolations,
hasNoticeTypeViolations,
isActionCreator,
Expand Down
16 changes: 2 additions & 14 deletions src/libs/TransactionUtils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import {toLocaleDigit} from '@libs/LocaleDigitUtils';
import * as Localize from '@libs/Localize';
import * as NumberUtils from '@libs/NumberUtils';
import Permissions from '@libs/Permissions';
import * as PolicyUtils from '@libs/PolicyUtils';
import {getCleanedTagName, getDistanceRateCustomUnitRate} from '@libs/PolicyUtils';
import * as PolicyUtils from '@libs/PolicyUtils';
// eslint-disable-next-line import/no-cycle
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportConnection from '@libs/ReportConnection';
import * as ReportUtils from '@libs/ReportUtils';
import type {IOURequestType} from '@userActions/IOU';
import type {IOUType} from '@src/CONST';
import CONST from '@src/CONST';
import type {IOUType} from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {Beta, OnyxInputOrEntry, Policy, RecentWaypoint, Report, ReviewDuplicates, TaxRate, TaxRates, Transaction, TransactionViolation, TransactionViolations} from '@src/types/onyx';
import type {Attendee} from '@src/types/onyx/IOU';
Expand Down Expand Up @@ -872,17 +872,6 @@ function hasViolation(transactionID: string, transactionViolations: OnyxCollecti
);
}

/**
* Checks if any non-hold violations for the provided transaction are of type 'violation'
*/
function hasNonHoldViolation(transactionID: string, transactionViolations: OnyxCollection<TransactionViolations>, showInReview?: boolean): boolean {
return !!transactionViolations?.[ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS + transactionID]?.some(
(violation: TransactionViolation) =>
violation.type === CONST.VIOLATION_TYPES.VIOLATION &&
violation.name !== CONST.VIOLATIONS.HOLD &&
(showInReview === undefined || showInReview === (violation.showInReview ?? false)),
);
}
/**
* Checks if any violations for the provided transaction are of type 'notice'
*/
Expand Down Expand Up @@ -1303,7 +1292,6 @@ export {
getRecentTransactions,
hasReservationList,
hasViolation,
hasNonHoldViolation,
hasBrokenConnectionViolation,
shouldShowBrokenConnectionViolation,
hasNoticeTypeViolation,
Expand Down
8 changes: 4 additions & 4 deletions src/libs/actions/IOU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6836,7 +6836,7 @@ function canApproveIOU(
const reportNameValuePairs = chatReportRNVP ?? ReportUtils.getReportNameValuePairs(iouReport?.reportID);
const isArchivedReport = ReportUtils.isArchivedRoom(iouReport, reportNameValuePairs);
const allViolations = violations ?? allTransactionViolations;
const hasNonHoldViolation = ReportUtils.hasNonHoldViolation(iouReport?.reportID ?? '-1', allViolations);
const hasViolations = ReportUtils.hasViolations(iouReport?.reportID ?? '-1', allViolations);
let isTransactionBeingScanned = false;
const reportTransactions = TransactionUtils.getAllReportTransactions(iouReport?.reportID);
for (const transaction of reportTransactions) {
Expand All @@ -6849,7 +6849,7 @@ function canApproveIOU(
}
}

return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled && !isArchivedReport && !isTransactionBeingScanned && !hasNonHoldViolation;
return isCurrentUserManager && !isOpenExpenseReport && !isApproved && !iouSettled && !isArchivedReport && !isTransactionBeingScanned && !hasViolations;
}

function canIOUBePaid(
Expand Down Expand Up @@ -6906,7 +6906,7 @@ function canIOUBePaid(
const isAutoReimbursable = policy?.reimbursementChoice === CONST.POLICY.REIMBURSEMENT_CHOICES.REIMBURSEMENT_YES ? false : ReportUtils.canBeAutoReimbursed(iouReport, policy);
const allViolations = violations ?? allTransactionViolations;
const shouldBeApproved = canApproveIOU(iouReport, policy, allViolations);
const hasNonHoldViolation = ReportUtils.hasNonHoldViolation(iouReport?.reportID ?? '-1', allViolations);
const hasViolations = ReportUtils.hasViolations(iouReport?.reportID ?? '-1', allViolations);

const isPayAtEndExpenseReport = ReportUtils.isPayAtEndExpenseReport(iouReport?.reportID, transactions);
return (
Expand All @@ -6918,7 +6918,7 @@ function canIOUBePaid(
!isChatReportArchived &&
!isAutoReimbursable &&
!shouldBeApproved &&
!hasNonHoldViolation &&
!hasViolations &&
!isPayAtEndExpenseReport
);
}
Expand Down

0 comments on commit 3f9bf24

Please sign in to comment.