Skip to content

Newsletter: hide Comp action when the site has no paid plans#49531

Open
CGastrell wants to merge 1 commit into
trunkfrom
change/newsletter-comp-gate-paid-plans
Open

Newsletter: hide Comp action when the site has no paid plans#49531
CGastrell wants to merge 1 commit into
trunkfrom
change/newsletter-comp-gate-paid-plans

Conversation

@CGastrell

@CGastrell CGastrell commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Part of #49485 - NL06

Proposed changes

On a site with no paid newsletter plans, the Subscribers tab no longer offers the "Comp a subscription" action. Previously the action appeared for any subscriber with a WordPress.com user id and then opened a modal that only reported "you don't have any paid plans" — a dead end.

  • The site's membership products are now fetched once at the Subscribers table level (via the existing useMembershipsProducts hook, hoisted out of the Comp modal) and the action's isEligible is gated on whether any paid product exists. The per-row check reuses that single result, so no per-row network requests are introduced.
  • While products are still loading / unknown, the action stays hidden — preferring "no dead-end" over a momentary availability flicker.
  • On a site with paid plans, behavior is unchanged: the action shows for subscribers with a wpcom user id, and the modal still handles the per-subscriber "already comped on every plan" edge case.
  • Removed the now-unreachable "no paid newsletter plans configured" info notice from the Comp modal (the modal can no longer open in that state). The Comp request flow itself is untouched.

Related product discussion/links

Does this pull request change what data or activity we track or use?

No. No new tracking. The same useMembershipsProducts request that the Comp modal already made now also runs when the Subscribers table mounts (one extra fetch per page load on a connection-gated tab, deduped via the shared React Query cache the modal already used).

Testing instructions

This change is on the modernized Subscribers dashboard, which is behind a feature flag and requires a WordPress.com connection (the membership-products request is proxied to WordPress.com), so it needs a connected newsletter site to verify the two states.

No paid plans (the fix):

  1. On a connected site with the modernized Subscribers dashboard enabled and no paid newsletter products configured, open the Subscribers tab.
  2. Open a subscriber row's action menu (and select a row for the bulk-action menu).
  3. Confirm "Comp a subscription" does not appear in either menu. The other actions (View, Remove comp where applicable, Remove subscriber) are unaffected.

With paid plans (unchanged):

  1. On a connected site that has at least one paid newsletter product, open the Subscribers tab.
  2. For a subscriber with a WordPress.com user id, confirm "Comp a subscription" still appears and opens the working Comp modal.

No extra per-row requests:

  • With the Network tab open while scrolling the subscribers table, confirm only a single memberships/products request fires for the page (not one per row).

@CGastrell CGastrell self-assigned this Jun 10, 2026
@CGastrell CGastrell added [Package] Newsletter Bug When a feature is broken and / or not performing as intended labels Jun 10, 2026
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the change/newsletter-comp-gate-paid-plans branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack change/newsletter-comp-gate-paid-plans

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: July 7, 2026
    • Code freeze: July 6, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@jp-launch-control

jp-launch-control Bot commented Jun 10, 2026

Copy link
Copy Markdown

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report · JS report

@CGastrell CGastrell added [Status] Needs Review This PR is ready for review. [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ and removed [Status] In Progress labels Jun 10, 2026
@CGastrell CGastrell marked this pull request as ready for review June 10, 2026 17:24
@enejb enejb requested a review from Copilot June 10, 2026 19:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the Newsletter Subscribers UI by preventing users from hitting a dead-end “Comp a subscription” flow on sites that have no paid newsletter plans configured.

Changes:

  • Hoists the membership products fetch to the Subscribers table level and uses it to gate whether the “Comp a subscription” action is offered.
  • Updates the memberships-products hook docblock to reflect the new shared/cached usage between table + modal.
  • Removes the “no paid plans configured” notice from the Comp modal since the modal should no longer be reachable in that state.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
projects/packages/newsletter/changelog/change-newsletter-comp-gate-paid-plans Adds a changelog entry documenting the UI behavior change.
projects/packages/newsletter/_inc/subscribers/data/use-memberships-products.ts Updates hook documentation to reflect table-level usage and cache reuse.
projects/packages/newsletter/_inc/subscribers/components/subscribers-data-views.tsx Fetches products once at table level and gates the Comp action on “paid products exist”.
projects/packages/newsletter/_inc/subscribers/components/modals/comp-modal.tsx Removes the “no paid plans configured” notice that should now be unreachable.

The "Comp a subscription" Subscribers action previously appeared for any
subscriber with a wpcom user id, then opened a modal that only reported
"no paid plans" when the site had none — a dead end.

Fetch the site's membership products once at the table level and gate the
action's availability on whether any paid product exists, so the action is
only offered when there's something to comp onto. The per-row eligibility
check reuses that single result, adding no per-row network requests. Remove
the now-unreachable "no paid plans" notice from the Comp modal.
@CGastrell CGastrell force-pushed the change/newsletter-comp-gate-paid-plans branch from 890e606 to cbcf644 Compare June 10, 2026 21:01
@CGastrell

Copy link
Copy Markdown
Contributor Author

Thanks @copilot — good catch on the error-state behavior. Addressed in the latest push.

The valid issue: gating isEligible on hasPaidProducts made the action disappear on a products-fetch error too, not just on a genuinely empty site. Since the modal is the only place that surfaces a products error (it has an error Notice), hiding the action on error silently removed the capability with no feedback — a regression vs. the prior always-visible behavior.

Fix: derive a dedicated gate that fails open on error:

const { data: membershipsProducts, isError: membershipsProductsError } =
	useMembershipsProducts( true );
const hasPaidProducts = ( membershipsProducts?.length ?? 0 ) > 0;
// Show when products exist OR when we couldn't determine them (fetch error); stay hidden only
// while loading and on a genuinely empty site.
const canShowCompAction = hasPaidProducts || membershipsProductsError;

isEligible now gates on canShowCompAction, and the actions memo dep list tracks canShowCompAction. Net behavior: loading → hidden (no flicker), zero products → hidden (the dead-end this PR targets), error → shown so the modal can surface the fetch error, has products → shown.

On the memo-dependency note: the previous dep list already included hasPaidProducts (no stale-eligibility bug there), but it now correctly tracks the new canShowCompAction gate instead.

eslint + tsgo + the newsletter Jest suite pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug When a feature is broken and / or not performing as intended [Package] Newsletter [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Status] Needs Review This PR is ready for review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants