Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {
navigateToDetailsPage,
reportTransactionsSelector,
} from '@libs/ReportUtils';
import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils';
import {
allHavePendingRTERViolation,
hasDuplicateTransactions,
Expand Down Expand Up @@ -484,6 +485,10 @@ function MoneyReportHeader({
if (!moneyRequestReport?.reportID) {
return;
}
if (policy && shouldRestrictUserBillableActions(policy.id)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
startMoneyRequest(CONST.IOU.TYPE.SUBMIT, moneyRequestReport?.reportID);
},
},
Expand All @@ -492,11 +497,15 @@ function MoneyReportHeader({
text: translate('iou.addUnreportedExpense'),
icon: Expensicons.ReceiptPlus,
onSelected: () => {
if (policy && shouldRestrictUserBillableActions(policy.id)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
openUnreportedExpense(moneyRequestReport?.reportID);
},
},
],
[moneyRequestReport?.reportID, translate],
[moneyRequestReport?.reportID, policy, translate],
);

const primaryActionsImplementation = {
Expand Down Expand Up @@ -848,6 +857,10 @@ function MoneyReportHeader({
if (!moneyRequestReport?.reportID) {
return;
}
if (policy && shouldRestrictUserBillableActions(policy.id)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
startMoneyRequest(CONST.IOU.TYPE.SUBMIT, moneyRequestReport?.reportID);
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import {
isWaitingForSubmissionFromCurrentUser as isWaitingForSubmissionFromCurrentUserReportUtils,
} from '@libs/ReportUtils';
import shouldAdjustScroll from '@libs/shouldAdjustScroll';
import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils';
import {hasPendingUI, isCardTransaction, isPending} from '@libs/TransactionUtils';
import colors from '@styles/theme/colors';
import variables from '@styles/variables';
Expand Down Expand Up @@ -471,6 +472,10 @@ function MoneyRequestReportPreviewContent({
if (!iouReport?.reportID) {
return;
}
if (policy && shouldRestrictUserBillableActions(policy.id)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
startMoneyRequest(CONST.IOU.TYPE.SUBMIT, iouReport?.reportID, undefined, false, chatReportID);
},
},
Expand All @@ -479,11 +484,15 @@ function MoneyRequestReportPreviewContent({
text: translate('iou.addUnreportedExpense'),
icon: Expensicons.ReceiptPlus,
onSelected: () => {
if (policy && shouldRestrictUserBillableActions(policy.id)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
openUnreportedExpense(iouReport?.reportID, iouReport?.parentReportID);
},
},
],
[chatReportID, iouReport?.parentReportID, iouReport?.reportID, translate],
[chatReportID, iouReport?.parentReportID, iouReport?.reportID, policy, translate],
);

const isReportDeleted = action?.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE;
Expand Down
11 changes: 10 additions & 1 deletion src/components/ReportActionItem/ReportPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import {
isWaitingForSubmissionFromCurrentUser as isWaitingForSubmissionFromCurrentUserReportUtils,
} from '@libs/ReportUtils';
import StringUtils from '@libs/StringUtils';
import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils';
import {
getDescription,
getMerchant,
Expand Down Expand Up @@ -513,6 +514,10 @@ function ReportPreview({
if (!iouReport?.reportID) {
return;
}
if (policy && shouldRestrictUserBillableActions(policy.id)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
startMoneyRequest(CONST.IOU.TYPE.SUBMIT, iouReport?.reportID, undefined, false, chatReportID);
},
},
Expand All @@ -521,11 +526,15 @@ function ReportPreview({
text: translate('iou.addUnreportedExpense'),
icon: Expensicons.ReceiptPlus,
onSelected: () => {
if (policy && shouldRestrictUserBillableActions(policy.id)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
openUnreportedExpense(iouReport?.reportID, iouReport?.parentReportID);
},
},
],
[chatReportID, iouReport?.parentReportID, iouReport?.reportID, translate],
[chatReportID, iouReport?.parentReportID, iouReport?.reportID, policy, translate],
);

const reportPreviewAction = useMemo(() => {
Expand Down
6 changes: 6 additions & 0 deletions src/pages/AddUnreportedExpense.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ import useThemeStyles from '@hooks/useThemeStyles';
import {fetchUnreportedExpenses} from '@libs/actions/UnreportedExpenses';
import interceptAnonymousUser from '@libs/interceptAnonymousUser';
import type {AddUnreportedExpensesParamList} from '@libs/Navigation/types';
import {shouldRestrictUserBillableActions} from '@libs/SubscriptionUtils';
import Navigation from '@navigation/Navigation';
import type {PlatformStackScreenProps} from '@navigation/PlatformStackNavigation/types';
import {startMoneyRequest} from '@userActions/IOU';
import {changeTransactionsReport} from '@userActions/Transaction';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import type Transaction from '@src/types/onyx/Transaction';
import NewChatSelectorPage from './NewChatSelectorPage';
Expand Down Expand Up @@ -120,6 +122,10 @@ function AddUnreportedExpense({route}: AddUnreportedExpensePageType) {
{
buttonText: translate('iou.createExpense'),
buttonAction: () => {
if (report && report.policyID && shouldRestrictUserBillableActions(report.policyID)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(report.policyID));
return;
}
interceptAnonymousUser(() => {
startMoneyRequest(CONST.IOU.TYPE.SUBMIT, reportID, undefined, false, backToReport);
});
Expand Down
Loading