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
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function BaseFloatingCameraButton({icon}: BaseFloatingCameraButtonProps) {
const [session] = useOnyx(ONYXKEYS.SESSION, {selector: sessionSelector});
const [allTransactionDrafts] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION_DRAFT);
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 reportID = useMemo(() => generateReportID(), []);

const policyChatForActivePolicySelector = useCallback(
Expand All @@ -54,7 +55,10 @@ function BaseFloatingCameraButton({icon}: BaseFloatingCameraButtonProps) {

const onPress = () => {
interceptAnonymousUser(() => {
if (policyChatForActivePolicy?.policyID && shouldRestrictUserBillableActions(policyChatForActivePolicy.policyID, userBillingGraceEndPeriods)) {
if (
policyChatForActivePolicy?.policyID &&
shouldRestrictUserBillableActions(policyChatForActivePolicy.policyID, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod)
) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policyChatForActivePolicy.policyID));
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/MoneyReportHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@
}, [iouTransactionID, requestParentReportAction, transactionThreadReport?.reportID, transactionViolations]);

const [allPolicyTags] = useOnyx(ONYXKEYS.COLLECTION.POLICY_TAGS);
const targetPolicyTags = defaultExpensePolicy ? (allPolicyTags?.[`${ONYXKEYS.COLLECTION.POLICY_TAGS}${defaultExpensePolicy.id}`] ?? {}) : {};

Check warning on line 728 in src/components/MoneyReportHeader.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

The 'targetPolicyTags' conditional could make the dependencies of useCallback Hook (at line 767) change on every render. Move it inside the useCallback callback. Alternatively, wrap the initialization of 'targetPolicyTags' in its own useMemo() Hook

Check warning on line 728 in src/components/MoneyReportHeader.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

The 'targetPolicyTags' conditional could make the dependencies of useCallback Hook (at line 767) change on every render. Move it inside the useCallback callback. Alternatively, wrap the initialization of 'targetPolicyTags' in its own useMemo() Hook

const duplicateExpenseTransaction = useCallback(
(transactionList: OnyxTypes.Transaction[]) => {
Expand Down Expand Up @@ -1725,7 +1725,7 @@
if (!moneyRequestReport?.reportID) {
return;
}
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriods, ownerBillingGraceEndPeriod)) {
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Putting in my K2

Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
Expand Down Expand Up @@ -1859,7 +1859,7 @@
}
return option;
});
}, [originalSelectedTransactionsOptions, showDeleteModal, dismissedRejectUseExplanation]);

Check warning on line 1862 in src/components/MoneyReportHeader.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useMemo has missing dependencies: 'isDelegateAccessRestricted' and 'showDelegateNoAccessModal'. Either include them or remove the dependency array

Check warning on line 1862 in src/components/MoneyReportHeader.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useMemo has missing dependencies: 'isDelegateAccessRestricted' and 'showDelegateNoAccessModal'. Either include them or remove the dependency array

const shouldShowSelectedTransactionsButton = !!selectedTransactionsOptions.length && !transactionThreadReportID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const minModalHeight = 380;

function SearchMoneyRequestReportEmptyState({report, policy}: {report: OnyxTypes.Report; policy?: OnyxTypes.Policy}) {
const [userBillingGraceEndPeriodCollection] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${report.reportID}`);
const {translate} = useLocalize();
const styles = useThemeStyles();
Expand All @@ -39,7 +40,7 @@ function SearchMoneyRequestReportEmptyState({report, policy}: {report: OnyxTypes
if (!reportId) {
return;
}
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriodCollection)) {
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriodCollection, undefined, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
Expand All @@ -54,7 +55,7 @@ function SearchMoneyRequestReportEmptyState({report, policy}: {report: OnyxTypes
if (!reportId) {
return;
}
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriodCollection)) {
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriodCollection, undefined, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
Expand All @@ -66,7 +67,7 @@ function SearchMoneyRequestReportEmptyState({report, policy}: {report: OnyxTypes
text: translate('iou.addUnreportedExpense'),
icon: icons.ReceiptPlus,
onSelected: () => {
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriodCollection)) {
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriodCollection, undefined, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function SearchFiltersBarCreateButton() {
const hasViolations = hasViolationsReportUtils(undefined, transactionViolations, session?.accountID ?? CONST.DEFAULT_NUMBER_ID, session?.email ?? '');
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [activePolicy] = useOnyx(`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`);
const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
const {policyForMovingExpensesID, shouldSelectPolicy} = usePolicyForMovingExpenses();
const shouldNavigateToUpgradePath = !policyForMovingExpensesID && !shouldSelectPolicy;
const {showConfirmModal} = useConfirmModal();
Expand Down Expand Up @@ -179,13 +180,16 @@ function SearchFiltersBarCreateButton() {
const workspaceIDForReportCreation = defaultChatEnabledPolicyID;

// No default or restricted with multiple workspaces → workspace selector
if (!workspaceIDForReportCreation || (shouldRestrictUserBillableActions(workspaceIDForReportCreation) && groupPoliciesWithChatEnabled.length > 1)) {
if (
!workspaceIDForReportCreation ||
(shouldRestrictUserBillableActions(workspaceIDForReportCreation, undefined, undefined, ownerBillingGraceEndPeriod) && groupPoliciesWithChatEnabled.length > 1)
) {
Navigation.navigate(ROUTES.NEW_REPORT_WORKSPACE_SELECTION.getRoute());
return;
}

// Default workspace is not restricted → create report directly
if (!shouldRestrictUserBillableActions(workspaceIDForReportCreation)) {
if (!shouldRestrictUserBillableActions(workspaceIDForReportCreation, undefined, undefined, ownerBillingGraceEndPeriod)) {
// Check if empty report confirmation should be shown
if (shouldShowEmptyReportConfirmationForDefaultChatEnabledPolicy) {
openCreateReportConfirmation();
Expand Down
3 changes: 2 additions & 1 deletion src/components/SettlementButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ function SettlementButton({
const [personalPolicyID] = useOnyx(ONYXKEYS.PERSONAL_POLICY_ID);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [userBillingGraceEndPeriods] = useOnyx(ONYXKEYS.COLLECTION.SHARED_NVP_PRIVATE_USER_BILLING_GRACE_PERIOD_END);
const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
Copy link
Contributor

Choose a reason for hiding this comment

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

@truph01 @shubham1206agra This change prevents SettlementButton from being memoized by the React Compiler. Could you please check this?
cc @roryabraham Since we already removed the manual memoization here

Image

Copy link
Contributor

Choose a reason for hiding this comment

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

@linhvovan29546 Please ask the same in #80252 as this PR added the memoization back

Copy link
Contributor

@linhvovan29546 linhvovan29546 Mar 18, 2026

Choose a reason for hiding this comment

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

@shubham1206agra We merged the latest PR two weeks ago #81818 So it's not caused by #80252

Copy link
Contributor

Choose a reason for hiding this comment

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

@linhvovan29546 The memoization is still present in the file so it's not our fault

Copy link
Contributor

Choose a reason for hiding this comment

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

My mistake, I referenced the wrong here. To clarify: the memoization is caused by PR #83638


const lastPaymentMethod = iouReport?.type
? getLastPolicyPaymentMethod(policyIDKey, personalPolicyID, lastPaymentMethods, iouReport?.type as keyof LastPaymentMethodType, isIOUReport(iouReport))
Expand Down Expand Up @@ -180,7 +181,7 @@ function SettlementButton({
return true;
}

if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriods)) {
if (policy && shouldRestrictUserBillableActions(policy.id, userBillingGraceEndPeriods, undefined, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/AddUnreportedExpense.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function AddUnreportedExpense({route}: AddUnreportedExpensePageType) {
const [isLoadingUnreportedTransactions] = useOnyx(ONYXKEYS.IS_LOADING_UNREPORTED_TRANSACTIONS);
const [cardList] = useOnyx(ONYXKEYS.CARD_LIST);
const {accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
const shouldShowUnreportedTransactionsSkeletons = isLoadingUnreportedTransactions && hasMoreUnreportedTransactionsResults && !isOffline;

const getUnreportedTransactions = useCallback(
Expand Down Expand Up @@ -279,7 +280,7 @@ function AddUnreportedExpense({route}: AddUnreportedExpensePageType) {
{
buttonText: translate('iou.createExpense'),
buttonAction: () => {
if (report && report.policyID && shouldRestrictUserBillableActions(report.policyID)) {
if (report && report.policyID && shouldRestrictUserBillableActions(report.policyID, undefined, undefined, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(report.policyID));
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/NewReportWorkspaceSelectionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ function NewReportWorkspaceSelectionPage({route}: NewReportWorkspaceSelectionPag
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [hasDismissedEmptyReportsConfirmation] = useOnyx(ONYXKEYS.NVP_EMPTY_REPORTS_CONFIRMATION_DISMISSED);
const [betas] = useOnyx(ONYXKEYS.BETAS);
const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
const [policies, fetchStatus] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const [allTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION);
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
Expand Down Expand Up @@ -180,7 +181,7 @@ function NewReportWorkspaceSelectionPage({route}: NewReportWorkspaceSelectionPag
return;
}

if (shouldRestrictUserBillableActions(policy.policyID)) {
if (shouldRestrictUserBillableActions(policy.policyID, undefined, undefined, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.policyID));
return;
}
Expand Down
4 changes: 3 additions & 1 deletion src/pages/ReportChangeWorkspacePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,15 @@ function ReportChangeWorkspacePage({report, route}: ReportChangeWorkspacePagePro
const isASAPSubmitBetaEnabled = isBetaEnabled(CONST.BETAS.ASAP_SUBMIT);
const session = useSession();
const hasViolations = hasViolationsReportUtils(report?.reportID, transactionViolations, session?.accountID ?? CONST.DEFAULT_NUMBER_ID, session?.email ?? '');
const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);

const selectPolicy = useCallback(
(policyID?: string) => {
const policy = policies?.[`${ONYXKEYS.COLLECTION.POLICY}${policyID}`];
if (!policyID || !policy) {
return;
}
if (shouldRestrictUserBillableActions(policy.id)) {
if (shouldRestrictUserBillableActions(policy.id, undefined, undefined, ownerBillingGraceEndPeriod)) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(policy.id));
return;
}
Expand Down Expand Up @@ -124,6 +125,7 @@ function ReportChangeWorkspacePage({report, route}: ReportChangeWorkspacePagePro
},
[
policies,
ownerBillingGraceEndPeriod,
route.params,
reportID,
report,
Expand Down
6 changes: 4 additions & 2 deletions src/pages/Search/EmptySearchView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ function EmptySearchViewContent({
});
const hasViolations = hasViolationsReportUtils(undefined, transactionViolations, accountID ?? CONST.DEFAULT_NUMBER_ID, '');

const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
const [hasTransactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, {
selector: hasTransactionsSelector,
});
Expand Down Expand Up @@ -339,14 +340,15 @@ function EmptySearchViewContent({

if (
!workspaceIDForReportCreation ||
(shouldRestrictUserBillableActions(workspaceIDForReportCreation) && groupPoliciesWithChatEnabled.length > 1)
(shouldRestrictUserBillableActions(workspaceIDForReportCreation, undefined, undefined, ownerBillingGraceEndPeriod) &&
groupPoliciesWithChatEnabled.length > 1)
) {
// If we couldn't guess the workspace to create the report, or a guessed workspace is past it's grace period and we have other workspaces to choose from
Navigation.navigate(ROUTES.NEW_REPORT_WORKSPACE_SELECTION.getRoute());
return;
}

if (!shouldRestrictUserBillableActions(workspaceIDForReportCreation)) {
if (!shouldRestrictUserBillableActions(workspaceIDForReportCreation, undefined, undefined, ownerBillingGraceEndPeriod)) {
handleCreateReportClick();
} else {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(workspaceIDForReportCreation));
Expand Down
9 changes: 7 additions & 2 deletions src/pages/iou/request/MoneyRequestParticipantsSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ function MoneyRequestParticipantsSelector({
const [activePolicyID] = useOnyx(ONYXKEYS.NVP_ACTIVE_POLICY_ID);
const [allPolicies] = useOnyx(ONYXKEYS.COLLECTION.POLICY);
const policy = allPolicies?.[`${ONYXKEYS.COLLECTION.POLICY}${activePolicyID}`];
const [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);
const [isSearchingForReports] = useOnyx(ONYXKEYS.IS_SEARCHING_FOR_REPORTS, {initWithStoredValues: false});
const currentUserPersonalDetails = useCurrentUserPersonalDetails();
const currentUserLogin = currentUserPersonalDetails.login;
Expand Down Expand Up @@ -513,7 +514,11 @@ function MoneyRequestParticipantsSelector({

const onSelectRow = useCallback(
(option: Participant) => {
if (option.isPolicyExpenseChat && option.policyID && shouldRestrictUserBillableActions(option.policyID, userBillingGraceEndPeriodCollection)) {
if (
option.isPolicyExpenseChat &&
option.policyID &&
shouldRestrictUserBillableActions(option.policyID, userBillingGraceEndPeriodCollection, undefined, ownerBillingGraceEndPeriod)
) {
Navigation.navigate(ROUTES.RESTRICTED_ACTION.getRoute(option.policyID));
return;
}
Expand All @@ -525,7 +530,7 @@ function MoneyRequestParticipantsSelector({

addSingleParticipant(option);
},
[isIOUSplit, addParticipantToSelection, addSingleParticipant, userBillingGraceEndPeriodCollection],
[isIOUSplit, addParticipantToSelection, addSingleParticipant, userBillingGraceEndPeriodCollection, ownerBillingGraceEndPeriod],
);

const importContactsButtonComponent = useMemo(() => {
Expand Down
6 changes: 5 additions & 1 deletion src/pages/iou/request/step/IOURequestStepParticipants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,15 @@ 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 [ownerBillingGraceEndPeriod] = useOnyx(ONYXKEYS.NVP_PRIVATE_OWNER_BILLING_GRACE_PERIOD_END);

const currentUserPersonalDetails = useCurrentUserPersonalDetails();

const isActivePolicyRequest =
iouType === CONST.IOU.TYPE.CREATE && isPaidGroupPolicy(activePolicy) && activePolicy?.isPolicyExpenseChatEnabled && !shouldRestrictUserBillableActions(activePolicy.id);
iouType === CONST.IOU.TYPE.CREATE &&
isPaidGroupPolicy(activePolicy) &&
activePolicy?.isPolicyExpenseChatEnabled &&
!shouldRestrictUserBillableActions(activePolicy.id, undefined, undefined, ownerBillingGraceEndPeriod);

const isAndroidNative = getPlatform() === CONST.PLATFORM.ANDROID;
const isMobileSafari = isMobileSafariBrowser();
Expand Down
Loading
Loading