Commit 7dcbc074b9a for woocommerce

commit 7dcbc074b9a5c9411f2ee9dbaaf3e3761e79948a
Author: Justin P <228780+layoutd@users.noreply.github.com>
Date:   Thu Oct 22 10:29:54 2026 +0200

    Add regression test for Analytics default order status superset guard (#69873)

    * Add regression test for Analytics default order status superset guard

    * Tighten Analytics default status guard comment and move superset precondition assertion

diff --git a/plugins/woocommerce/changelog/dev-analytics-default-status-superset-test b/plugins/woocommerce/changelog/dev-analytics-default-status-superset-test
new file mode 100644
index 00000000000..bc00c3251a0
--- /dev/null
+++ b/plugins/woocommerce/changelog/dev-analytics-default-status-superset-test
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Pin the Analytics default order status guard's superset case with a regression test; no production change.
diff --git a/plugins/woocommerce/src/Internal/Admin/Settings.php b/plugins/woocommerce/src/Internal/Admin/Settings.php
index c6b1cd22123..8104b099d59 100644
--- a/plugins/woocommerce/src/Internal/Admin/Settings.php
+++ b/plugins/woocommerce/src/Internal/Admin/Settings.php
@@ -250,8 +250,8 @@ class Settings {
 			return $value;
 		}

-		// The page shows the built-in default when a filter returns only statuses it cannot display.
-		// Deleting the option then would switch reports to the filter's list, so store what was shown.
+		// The page shows the built-in default when a filter returns only statuses it cannot display. Deleting the option
+		// then would switch reports to the filter's list, so store what was shown. Extra undisplayable statuses still delete it.
 		$runtime_default = 'woocommerce_excluded_report_order_statuses' === $option['id']
 			? self::get_default_excluded_order_statuses()
 			: self::get_default_actionable_order_statuses();
diff --git a/plugins/woocommerce/tests/php/src/Internal/Admin/SettingsTest.php b/plugins/woocommerce/tests/php/src/Internal/Admin/SettingsTest.php
index c04b69f3571..a21bc0013e1 100644
--- a/plugins/woocommerce/tests/php/src/Internal/Admin/SettingsTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/Admin/SettingsTest.php
@@ -407,6 +407,26 @@ class SettingsTest extends WC_Unit_Test_Case {
 		$this->assertSame( array( 'pending', 'cancelled', 'failed' ), get_option( 'woocommerce_excluded_report_order_statuses' ), 'The shown list differs from the runtime default, so it must be stored.' );
 	}

+	/**
+	 * @testdox Saving the shown default when a filter adds an undisplayable status to the runtime default deletes the option, so the default filter keeps applying.
+	 */
+	public function test_saving_shown_default_deletes_option_when_runtime_default_is_superset(): void {
+		$callback = function ( $statuses ) {
+			return array_merge( $statuses, array( 'not-a-real-status' ) );
+		};
+		add_filter( 'woocommerce_analytics_settings_default_actionable_order_statuses', $callback );
+		$this->added_filters[] = array( 'woocommerce_analytics_settings_default_actionable_order_statuses', $callback );
+		update_option( 'woocommerce_actionable_order_statuses', array( 'processing' ) );
+
+		$setting = $this->find_setting( $this->get_wc_admin_group_settings(), 'woocommerce_actionable_order_statuses' );
+		$this->assertSame( array( 'processing', 'on-hold' ), $setting['default'], 'The page should drop the status it cannot display.' );
+		$this->assertContains( 'not-a-real-status', Settings::get_default_actionable_order_statuses(), 'The runtime default should keep the status the page drops.' );
+
+		$this->save_wc_admin_setting( 'woocommerce_actionable_order_statuses', array( 'processing', 'on-hold' ) );
+
+		$this->assertFalse( get_option( 'woocommerce_actionable_order_statuses' ), 'The shown list is a subset of the runtime default, so it must not be stored.' );
+	}
+
 	/**
 	 * @testdox Saving an order status list that differs from the default stores it.
 	 */