Skip to content

Commit

Permalink
Refactor empty receipt component logic in MoneyRequestConfirmationLis…
Browse files Browse the repository at this point in the history
…t and MoneyTemporaryForRefactorRequestConfirmationList
  • Loading branch information
cdanwards committed Jan 22, 2024
1 parent 06d1c08 commit a2ff790
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
13 changes: 5 additions & 8 deletions src/components/MoneyRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,6 @@ function MoneyRequestConfirmationList(props) {
const isSplitBill = props.iouType === CONST.IOU.TYPE.SPLIT;
const isTypeSend = props.iouType === CONST.IOU.TYPE.SEND;

// A flag for checking if the associated policy is of type Team or Corporate ("Control" or "Collect")
const isFromPaidPolicy = props.policy && (props.policy.type === CONST.POLICY.TYPE.TEAM || props.policy.type === CONST.POLICY.TYPE.CORPORATE);

const isSplitWithScan = isSplitBill && props.isScanRequest;

const {unit, rate, currency} = props.mileageRate;
Expand Down Expand Up @@ -618,16 +615,16 @@ function MoneyRequestConfirmationList(props) {
isAuthTokenRequired={!_.isEmpty(receiptThumbnail)}
/>
) : (
```suggestion
isFromPaidPolicy &&
!isDistanceRequest &&
iouType === CONST.IOU.TYPE.REQUEST && (
// The empty receipt component should only show for IOU Requests of a paid policy ("Team" or "Corporate")
PolicyUtils.isPaidGroupPolicy(props.policy) &&
!props.isDistanceRequest &&
props.iouType === CONST.IOU.TYPE.REQUEST && (
<ReceiptEmptyState
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(
CONST.IOU.ACTION.CREATE,
iouType
props.iouType,
transaction.transactionID,
props.reportID,
Navigation.getActiveRouteWithoutParams(),
Expand Down
14 changes: 3 additions & 11 deletions src/components/MoneyTemporaryForRefactorRequestConfirmationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,6 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
const isTypeSplit = iouType === CONST.IOU.TYPE.SPLIT;
const isTypeSend = iouType === CONST.IOU.TYPE.SEND;

// A flag for checking if the associated policy is of type Team or Corporate ("Control" or "Collect")
const isFromPaidPolicy = policy && (policy.type === CONST.POLICY.TYPE.TEAM || policy.type === CONST.POLICY.TYPE.CORPORATE);

const {unit, rate, currency} = mileageRate;
const distance = lodashGet(transaction, 'routes.route0.distance', 0);
const shouldCalculateDistanceAmount = isDistanceRequest && iouAmount === 0;
Expand Down Expand Up @@ -652,19 +649,14 @@ function MoneyTemporaryForRefactorRequestConfirmationList({
isAuthTokenRequired={!_.isEmpty(receiptThumbnail)}
/>
) : (
isFromPaidPolicy &&
// The empty receipt component should only show for IOU Requests of a paid policy ("Team" or "Corporate")
PolicyUtils.isPaidGroupPolicy(policy) &&
!isDistanceRequest &&
iouType === CONST.IOU.TYPE.REQUEST && (
<ReceiptEmptyState
onPress={() =>
Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(
CONST.IOU.ACTION.CREATE,
iouType,
transaction.transactionID,
reportID,
Navigation.getActiveRouteWithoutParams(),
),
ROUTES.MONEY_REQUEST_STEP_SCAN.getRoute(CONST.IOU.ACTION.CREATE, iouType, transaction.transactionID, reportID, Navigation.getActiveRouteWithoutParams()),
)
}
/>
Expand Down

0 comments on commit a2ff790

Please sign in to comment.