Skip to content

Commit

Permalink
Merge pull request #45739 from Expensify/yuwen-rterViolation
Browse files Browse the repository at this point in the history
Remove unneccessary hiding of mark as cash button on submitted reports
  • Loading branch information
NikkiWines authored Jul 23, 2024
2 parents 0d70442 + 58fefc7 commit a3df238
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
const shouldShowSettlementButton = (shouldShowPayButton || shouldShowApproveButton) && !allHavePendingRTERViolation && !shouldShowExportIntegrationButton;

const shouldDisableSubmitButton = shouldShowSubmitButton && !ReportUtils.isAllowedToSubmitDraftExpenseReport(moneyRequestReport);
const shouldShowMarkAsCashButton = isDraft && allHavePendingRTERViolation;
const isFromPaidPolicy = policyType === CONST.POLICY.TYPE.TEAM || policyType === CONST.POLICY.TYPE.CORPORATE;
const shouldShowStatusBar = allHavePendingRTERViolation || hasOnlyHeldExpenses || hasScanningReceipt;
const shouldShowNextStep = !ReportUtils.isClosedExpenseReportWithNoExpenses(moneyRequestReport) && isFromPaidPolicy && !!nextStep?.message?.length && !shouldShowStatusBar;
Expand Down Expand Up @@ -304,7 +303,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
/>
</View>
)}
{shouldShowMarkAsCashButton && !shouldUseNarrowLayout && (
{allHavePendingRTERViolation && !shouldUseNarrowLayout && (
<View style={[styles.pv2]}>
<Button
medium
Expand Down Expand Up @@ -353,7 +352,7 @@ function MoneyReportHeader({policy, report: moneyRequestReport, transactionThrea
isDisabled={shouldDisableSubmitButton}
/>
)}
{shouldShowMarkAsCashButton && shouldUseNarrowLayout && (
{allHavePendingRTERViolation && shouldUseNarrowLayout && (
<Button
medium
success
Expand Down
9 changes: 2 additions & 7 deletions src/components/MoneyRequestHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
import Navigation from '@libs/Navigation/Navigation';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
import * as TransactionUtils from '@libs/TransactionUtils';
import variables from '@styles/variables';
import * as IOU from '@userActions/IOU';
Expand Down Expand Up @@ -58,15 +57,11 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow
const theme = useTheme();
const {translate} = useLocalize();
const [shouldShowHoldMenu, setShouldShowHoldMenu] = useState(false);
const isSelfDMTrackExpenseReport = ReportUtils.isTrackExpenseReport(report) && ReportUtils.isSelfDM(parentReport);
const moneyRequestReport = !isSelfDMTrackExpenseReport ? parentReport : undefined;
const isDraft = ReportUtils.isOpenExpenseReport(moneyRequestReport);
const isOnHold = TransactionUtils.isOnHold(transaction);
const isDuplicate = TransactionUtils.isDuplicate(transaction?.transactionID ?? '');
const {isSmallScreenWidth} = useWindowDimensions();

const hasAllPendingRTERViolations = TransactionUtils.allHavePendingRTERViolation([transaction?.transactionID ?? '-1']);
const shouldShowMarkAsCashButton = isDraft && hasAllPendingRTERViolations;

const markAsCash = useCallback(() => {
TransactionActions.markAsCash(transaction?.transactionID ?? '-1', report.reportID);
Expand Down Expand Up @@ -142,7 +137,7 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow
shouldShowBackButton={shouldUseNarrowLayout}
onBackButtonPress={onBackButtonPress}
>
{shouldShowMarkAsCashButton && !shouldUseNarrowLayout && (
{hasAllPendingRTERViolations && !shouldUseNarrowLayout && (
<Button
success
medium
Expand All @@ -163,7 +158,7 @@ function MoneyRequestHeader({report, parentReportAction, policy, shouldUseNarrow
/>
)}
</HeaderWithBackButton>
{shouldShowMarkAsCashButton && shouldUseNarrowLayout && (
{hasAllPendingRTERViolations && shouldUseNarrowLayout && (
<View style={[styles.ph5, styles.pb3]}>
<Button
medium
Expand Down

0 comments on commit a3df238

Please sign in to comment.