Skip to content

Commit

Permalink
Merge pull request #55150 from software-mansion-labs/fix/hide-pay-button
Browse files Browse the repository at this point in the history
  • Loading branch information
blimpich authored Jan 16, 2025
2 parents 46a5887 + 9a516a0 commit a24a613
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/components/BrokenConnectionDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import type {OnyxEntry} from 'react-native-onyx';
import {useOnyx} from 'react-native-onyx';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import * as PolicyUtils from '@libs/PolicyUtils';
import * as ReportUtils from '@libs/ReportUtils';
import {isInstantSubmitEnabled, isPolicyAdmin as isPolicyAdminPolicyUtils} from '@libs/PolicyUtils';
import {isCurrentUserSubmitter, isProcessingReport, isReportApproved, isReportManuallyReimbursed} from '@libs/ReportUtils';
import Navigation from '@navigation/Navigation';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand All @@ -26,11 +26,11 @@ type BrokenConnectionDescriptionProps = {
function BrokenConnectionDescription({transactionID, policy, report}: BrokenConnectionDescriptionProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const [transactionViolations] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID}`);
const [transactionViolations] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION_VIOLATIONS}${transactionID ?? CONST.DEFAULT_NUMBER_ID}`);

const brokenConnection530Error = transactionViolations?.find((violation) => violation.data?.rterType === CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION_530);
const brokenConnectionError = transactionViolations?.find((violation) => violation.data?.rterType === CONST.RTER_VIOLATION_TYPES.BROKEN_CARD_CONNECTION);
const isPolicyAdmin = PolicyUtils.isPolicyAdmin(policy);
const isPolicyAdmin = isPolicyAdminPolicyUtils(policy);

if (!brokenConnection530Error && !brokenConnectionError) {
return '';
Expand All @@ -40,7 +40,7 @@ function BrokenConnectionDescription({transactionID, policy, report}: BrokenConn
return translate('violations.brokenConnection530Error');
}

if (isPolicyAdmin && !ReportUtils.isCurrentUserSubmitter(report?.reportID)) {
if (isPolicyAdmin && !isCurrentUserSubmitter(report?.reportID)) {
return (
<>
{`${translate('violations.adminBrokenConnectionError')}`}
Expand All @@ -53,7 +53,7 @@ function BrokenConnectionDescription({transactionID, policy, report}: BrokenConn
);
}

if (ReportUtils.isReportApproved(report) || ReportUtils.isReportManuallyReimbursed(report) || (ReportUtils.isProcessingReport(report) && !PolicyUtils.isInstantSubmitEnabled(policy))) {
if (isReportApproved(report) || isReportManuallyReimbursed(report) || (isProcessingReport(report) && !isInstantSubmitEnabled(policy))) {
return translate('violations.memberBrokenConnectionError');
}

Expand Down
6 changes: 5 additions & 1 deletion src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
const shouldShowExportIntegrationButton = !shouldShowPayButton && !shouldShowSubmitButton && connectedIntegration && isAdmin && canBeExported(moneyRequestReport);

const shouldShowSettlementButton =
(shouldShowPayButton || shouldShowApproveButton) && !hasAllPendingRTERViolations && !shouldShowExportIntegrationButton && !shouldShowBrokenConnectionViolation;
!shouldShowSubmitButton &&
(shouldShowPayButton || shouldShowApproveButton) &&
!hasAllPendingRTERViolations &&
!shouldShowExportIntegrationButton &&
!shouldShowBrokenConnectionViolation;

const shouldDisableSubmitButton = shouldShowSubmitButton && !isAllowedToSubmitDraftExpenseReport(moneyRequestReport);
const isFromPaidPolicy = policyType === CONST.POLICY.TYPE.TEAM || policyType === CONST.POLICY.TYPE.CORPORATE;
Expand Down

0 comments on commit a24a613

Please sign in to comment.