Commit 982378557d for woocommerce

commit 982378557dfb21bdac0d35f8a4cfc6728f14cce1
Author: nibras shami <nibrasshami2002@gmail.com>
Date:   Thu Jan 15 13:34:06 2026 +0300

    Fix: Prevent analytics category breadcrumbs crash on missing parent (#58312)

    * Fix: prevent analytics category breadcrumbs crash when parent category is missing

    Fixes an issue where `getCategoryAncestorIds` throws if a parent category hasn't yet been loaded due to API pagination. This adds a guard to prevent the function from assuming all parent categories are available in the current map.

    * Remove Console logs

    * Add changefile(s) from automation for the following project(s): woocommerce, woocommerce/client/admin

    ---------

    Co-authored-by: woocommercebot <woocommercebot@users.noreply.github.com>

diff --git a/plugins/woocommerce/changelog/58312-fix-analytics-category-breadcrumbs-parent-null b/plugins/woocommerce/changelog/58312-fix-analytics-category-breadcrumbs-parent-null
new file mode 100644
index 0000000000..b957773852
--- /dev/null
+++ b/plugins/woocommerce/changelog/58312-fix-analytics-category-breadcrumbs-parent-null
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fixes an issue where Analytics > Categories would crash if a product category had a `parent` that no longer exists in the taxonomy tables due to manual deletion outside the admin UI.
\ No newline at end of file
diff --git a/plugins/woocommerce/client/admin/client/analytics/report/categories/breadcrumbs.js b/plugins/woocommerce/client/admin/client/analytics/report/categories/breadcrumbs.js
index 6673112322..099925b4c8 100644
--- a/plugins/woocommerce/client/admin/client/analytics/report/categories/breadcrumbs.js
+++ b/plugins/woocommerce/client/admin/client/analytics/report/categories/breadcrumbs.js
@@ -11,11 +11,15 @@ import { getNewPath, getPersistedQuery } from '@woocommerce/navigation';
 export default class CategoryBreadcrumbs extends Component {
 	getCategoryAncestorIds( category, categories ) {
 		const ancestors = [];
-		let parent = category.parent;
+		let parent = category?.parent;
+
 		while ( parent ) {
+			const parentCategory = categories.get( parent );
+			if ( ! parentCategory ) break;
 			ancestors.unshift( parent );
-			parent = categories.get( parent ).parent;
+			parent = parentCategory.parent;
 		}
+
 		return ancestors;
 	}