client/extensions/woocommerce/state/sites/product-categories/selectors.js
function getProductCategoryLabel( state, categoryId, siteId = getSelectedSiteId( state ) ) {
	const categoryState = getRawCategoryState( state, siteId );
	const categories = categoryState.items || {};
	const category = categories[ categoryId ];
	if ( ! category ) {
		return '';
	}
	if ( ! Number( category.parent ) ) {
		return category.name;
	}
	return getProductCategoryLabel( state, category.parent, siteId ) + ` - ${ category.name }`;
}
function getProductCategoryLabel( state, categoryId, siteId = getSelectedSiteId( state ) ) {
	const categoryState = getRawCategoryState( state, siteId );
	const categories = categoryState.items || {};
	const category = categories[ categoryId ];
	if ( ! category ) {
		return '';
	}
	if ( ! Number( category.parent ) ) {
		return category.name;
	}
	return getProductCategoryLabel( state, category.parent, siteId ) + ` - ${ category.name }`;
}
/*
Get the label for a given product, recursively including parent names.

@param {Object} state Global state tree
@param {Number} categoryId ID of the starting category.
@param {Number} [siteId] wpcom site id, if not provided, uses the selected site id.
@return {String} Label of given category, with all parents included