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
3 changes: 2 additions & 1 deletion src/pages/Search/SearchTransactionsChangeReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function SearchTransactionsChangeReport() {
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const [allPolicyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}`);
const [personalPolicyID] = useOnyx(ONYXKEYS.PERSONAL_POLICY_ID);
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const hasPerDiemTransactions = useHasPerDiemTransactions(selectedTransactionsKeys);
Expand Down Expand Up @@ -136,7 +137,7 @@ function SearchTransactionsChangeReport() {
Navigation.navigate(ROUTES.NEW_REPORT_WORKSPACE_SELECTION.getRoute(true));
return;
}
if (policyForMovingExpensesID && shouldRestrictUserBillableActions(policyForMovingExpensesID, undefined, undefined, ownerBillingGraceEndPeriod)) {
if (policyForMovingExpensesID && shouldRestrictUserBillableActions(policyForMovingExpensesID, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policyForMovingExpensesID));
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/iou/request/step/BaseRequestStepWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ function BaseRequestStepWorkspace({transaction, getPolicies, onSelectWorkspace}:

const {login: currentUserLogin} = useCurrentUserPersonalDetails();
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
const selectedWorkspace = transaction?.participants?.[0];
const customUnitPolicy = getPolicyByCustomUnitID(transaction, allPolicies);
Expand Down Expand Up @@ -79,7 +80,7 @@ function BaseRequestStepWorkspace({transaction, getPolicies, onSelectWorkspace}:

const selectWorkspace = (item: WorkspaceListItem) => {
const policyID = item.policyID;
if (shouldRestrictUserBillableActions(policyID, undefined, undefined, ownerBillingGraceEndPeriod)) {
if (shouldRestrictUserBillableActions(policyID, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policyID));
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/iou/request/step/IOURequestEditReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function IOURequestEditReport({route}: IOURequestEditReportProps) {
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
const session = useSession();
const [personalPolicyID] = useOnyx(ONYXKEYS.PERSONAL_POLICY_ID);
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const [allPolicyCategories] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY_CATEGORIES}`);
Expand Down Expand Up @@ -148,7 +149,7 @@ function IOURequestEditReport({route}: IOURequestEditReportProps) {
Navigation.navigate(ROUTES.NEW_REPORT_WORKSPACE_SELECTION.getRoute(true, backTo));
return;
}
if (policyForMovingExpensesID && shouldRestrictUserBillableActions(policyForMovingExpensesID, undefined, undefined, ownerBillingGraceEndPeriod)) {
if (policyForMovingExpensesID && shouldRestrictUserBillableActions(policyForMovingExpensesID, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policyForMovingExpensesID));
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/iou/request/step/IOURequestEditReportCommon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function IOURequestEditReportCommon({
const personalDetails = usePersonalDetails();
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const [allTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION);
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const [selectedReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${selectedReportID}`);
Expand Down Expand Up @@ -224,7 +225,7 @@ function IOURequestEditReportCommon({
return;
}

if (item?.policyID && shouldRestrictUserBillableActions(item.policyID, undefined, undefined, ownerBillingGraceEndPeriod)) {
if (item?.policyID && shouldRestrictUserBillableActions(item.policyID, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(item.policyID));
return;
Comment on lines +228 to 230
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Don't block moving an existing expense into another report

handleSelectReport() runs for the edit-report flow as well as the create flow, and in the edit case the parent selectReport callback only reassigns already-created transactions to another existing report. Adding shouldRestrictUserBillableActions() here means members/admins in a past-due workspace can no longer clean up an expense's report assignment, even though this path is not creating a new expense or a new report.

Useful? React with 👍 / 👎.

}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/iou/request/step/IOURequestStepDestination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function IOURequestStepDestination({
ref,
}: IOURequestStepDestinationProps) {
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
const reportPolicyID = getIOURequestPolicyID(transaction, report);
const policyID = reportPolicyID === CONST.POLICY.ID_FAKE ? getPolicyByCustomUnitID(transaction, allPolicies)?.id : reportPolicyID;
Expand Down Expand Up @@ -107,7 +108,7 @@ function IOURequestStepDestination({
};

const updateDestination = (destination: ListItem & {currency: string}) => {
if (openedFromStartPage && policy?.id && shouldRestrictUserBillableActions(policy.id, undefined, undefined, ownerBillingGraceEndPeriod)) {
if (openedFromStartPage && policy?.id && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/iou/request/step/IOURequestStepHours.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function IOURequestStepHours({
const policyID = explicitPolicyID ?? report?.policyID;
const isTransactionDraft = shouldUseTransactionDraft(action);
const [selectedTab] = useOnyx(`${ONYXKEYS.COLLECTION.SELECTED_TAB}${CONST.TAB.IOU_REQUEST_TYPE}`);
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
const {accountID} = useCurrentUserPersonalDetails();
const [policy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${policyID}`);
Expand Down Expand Up @@ -165,7 +166,7 @@ function IOURequestStepHours({
large={!isExtraSmallScreenHeight}
style={[styles.w100, canUseTouchScreen ? styles.mt5 : styles.mt0]}
onPress={() => {
if (policyID && shouldRestrictUserBillableActions(policyID, undefined, undefined, ownerBillingGraceEndPeriod)) {
if (policyID && shouldRestrictUserBillableActions(policyID, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policyID));
return;
Comment on lines +169 to 171
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip billing gating when saving an existing time entry

This button is also used on STEP_HOURS_EDIT (isEditingConfirmation === true), where saveTime() only updates the hours on an already-created request and then navigates back. With the new guard in front of saveTime(), non-owner users in a past-due workspace are now prevented from correcting existing time expenses, even though they are not initiating a new billable action.

Useful? React with 👍 / 👎.

}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/iou/request/step/IOURequestStepParticipants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ function IOURequestStepParticipants({
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`);
const [introSelected] = useOnyx(ONYXKEYS.NVP_INTRO_SELECTED);
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);

const currentUserPersonalDetails = useCurrentUserPersonalDetails();
Expand All @@ -121,7 +122,7 @@ function IOURequestStepParticipants({
iouType === CONST.IOU.TYPE.CREATE &&
isPaidGroupPolicy(activePolicy) &&
activePolicy?.isPolicyExpenseChatEnabled &&
!shouldRestrictUserBillableActions(activePolicy.id, undefined, undefined, ownerBillingGraceEndPeriod);
!shouldRestrictUserBillableActions(activePolicy.id, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod);

const isAndroidNative = getPlatform() === CONST.PLATFORM.ANDROID;
const isMobileSafari = isMobileSafariBrowser();
Expand Down
3 changes: 2 additions & 1 deletion src/pages/iou/request/step/IOURequestStepReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) {
const [selectedReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${selectedReportID}`);
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const [allPolicyCategories] = useOnyx(ONYXKEYS.COLLECTION.POLICY_CATEGORIES);
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
const [personalPolicyID] = useOnyx(ONYXKEYS.PERSONAL_POLICY_ID);
const {removeTransaction, setSelectedTransactions} = useSearchActionsContext();
Expand Down Expand Up @@ -270,7 +271,7 @@ function IOURequestStepReport({route, transaction}: IOURequestStepReportProps) {
Navigation.navigate(ROUTES.NEW_REPORT_WORKSPACE_SELECTION.getRoute(true, backTo));
return;
}
if (policyForMovingExpensesID && shouldRestrictUserBillableActions(policyForMovingExpensesID, undefined, undefined, ownerBillingGraceEndPeriod)) {
if (policyForMovingExpensesID && shouldRestrictUserBillableActions(policyForMovingExpensesID, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policyForMovingExpensesID));
return;
}
Expand Down
Loading