Skip to content

Commit

Permalink
Merge pull request Expensify#49782 from rezkiy37/chore/47302-invoicin…
Browse files Browse the repository at this point in the history
…g-clean-up

Uncomment invoicing feature lines
  • Loading branch information
madmax330 authored Oct 3, 2024
2 parents 90fc8fb + 60afa5e commit 91f610c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8023,7 +8023,7 @@ function hasMissingInvoiceBankAccount(iouReportID: string): boolean {
return false;
}

return invoiceReport?.ownerAccountID === currentUserAccountID && isEmptyObject(getPolicy(invoiceReport?.policyID)?.invoice?.bankAccount ?? {}) && isSettled(iouReportID);
return invoiceReport?.ownerAccountID === currentUserAccountID && !getPolicy(invoiceReport?.policyID)?.invoice?.bankAccount?.transferBankAccountID && isSettled(iouReportID);
}

function isExpenseReportWithoutParentAccess(report: OnyxEntry<Report>) {
Expand Down
7 changes: 3 additions & 4 deletions src/libs/actions/Policy/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3136,10 +3136,9 @@ function enablePolicyInvoicing(policyID: string, enabled: boolean) {

API.write(WRITE_COMMANDS.ENABLE_POLICY_INVOICING, parameters, onyxData);

// TODO: Uncomment the following line when the invoices screen is ready - https://github.com/Expensify/App/issues/45175.
// if (enabled && getIsNarrowLayout()) {
// navigateWhenEnableFeature(policyID);
// }
if (enabled && getIsNarrowLayout()) {
navigateWhenEnableFeature(policyID);
}
}

function openPolicyMoreFeaturesPage(policyID: string) {
Expand Down
25 changes: 7 additions & 18 deletions src/pages/home/report/ReportActionItemMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import type {ReactElement} from 'react';
import React from 'react';
import type {StyleProp, TextStyle, ViewStyle} from 'react-native';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import {useOnyx} from 'react-native-onyx';
import Button from '@components/Button';
import Text from '@components/Text';
import useLocalize from '@hooks/useLocalize';
Expand All @@ -14,16 +13,11 @@ import * as ReportUtils from '@libs/ReportUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {ReportAction, Transaction} from '@src/types/onyx';
import type {ReportAction} from '@src/types/onyx';
import TextCommentFragment from './comment/TextCommentFragment';
import ReportActionItemFragment from './ReportActionItemFragment';

type ReportActionItemMessageOnyxProps = {
/** The transaction linked to the report action. */
transaction: OnyxEntry<Transaction>;
};

type ReportActionItemMessageProps = ReportActionItemMessageOnyxProps & {
type ReportActionItemMessageProps = {
/** The report action */
action: ReportAction;

Expand All @@ -40,9 +34,10 @@ type ReportActionItemMessageProps = ReportActionItemMessageOnyxProps & {
reportID: string;
};

function ReportActionItemMessage({action, transaction, displayAsGroup, reportID, style, isHidden = false}: ReportActionItemMessageProps) {
function ReportActionItemMessage({action, displayAsGroup, reportID, style, isHidden = false}: ReportActionItemMessageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${ReportActionsUtils.getLinkedTransactionID(action) ?? -1}`);

const fragments = ReportActionsUtils.getReportActionMessageFragments(action);
const isIOUReport = ReportActionsUtils.isMoneyRequestAction(action);
Expand Down Expand Up @@ -133,9 +128,7 @@ function ReportActionItemMessage({action, transaction, displayAsGroup, reportID,
return;
}

// TODO: Uncomment the following line when the invoices screen is ready - https://github.com/Expensify/App/issues/45175.
// Navigation.navigate(ROUTES.WORKSPACE_INVOICES.getRoute(policyID))
Navigation.navigate(ROUTES.WORKSPACE_MORE_FEATURES.getRoute(policyID));
Navigation.navigate(ROUTES.WORKSPACE_INVOICES.getRoute(policyID));
};

return (
Expand All @@ -161,8 +154,4 @@ function ReportActionItemMessage({action, transaction, displayAsGroup, reportID,

ReportActionItemMessage.displayName = 'ReportActionItemMessage';

export default withOnyx<ReportActionItemMessageProps, ReportActionItemMessageOnyxProps>({
transaction: {
key: ({action}) => `${ONYXKEYS.COLLECTION.TRANSACTION}${ReportActionsUtils.getLinkedTransactionID(action) ?? -1}`,
},
})(ReportActionItemMessage);
export default ReportActionItemMessage;
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ function WorkspaceInvoicingDetailsName({route}: WorkspaceInvoicingDetailsNamePro
<AccessOrNotFoundWrapper
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]}
policyID={policyID}
// TODO: uncomment when CONST.POLICY.MORE_FEATURES.ARE_INVOICES_ENABLED is supported
// featureName={CONST.POLICY.MORE_FEATURES.ARE_INVOICES_ENABLED}
featureName={CONST.POLICY.MORE_FEATURES.ARE_INVOICES_ENABLED}
>
<ScreenWrapper
testID={WorkspaceInvoicingDetailsName.displayName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ function WorkspaceInvoicingDetailsWebsite({route}: WorkspaceInvoicingDetailsWebs
<AccessOrNotFoundWrapper
accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]}
policyID={policyID}
// TODO: uncomment when CONST.POLICY.MORE_FEATURES.ARE_INVOICES_ENABLED is supported
// featureName={CONST.POLICY.MORE_FEATURES.ARE_INVOICES_ENABLED}
featureName={CONST.POLICY.MORE_FEATURES.ARE_INVOICES_ENABLED}
>
<ScreenWrapper
testID={WorkspaceInvoicingDetailsWebsite.displayName}
Expand Down

0 comments on commit 91f610c

Please sign in to comment.