Changing Permalinks for Category Pages Only

is rare, but it would have to default as you run you want. This forces the operation that you need

function my_category_link( $termlink, $term_id ) {
  $term = get_term( $term_id, 'category' );
  $ancestors = get_ancestors($term_id, 'category');
  if( !count($ancestors) ) return $termlink;

  $hierarchical_slugs = array();
  foreach ( (array)$ancestors as $ancestor ) {
    $ancestor_term = get_term($ancestor, 'category');
    $hierarchical_slugs[] = $ancestor_term->slug;
  }
  $hierarchical_slugs[] = $term->slug;
  return home_url( user_trailingslashit(implode("https://wordpress.stackexchange.com/", $hierarchical_slugs), 'category') )."\n";
}

add_filter( 'category_link', 'my_category_link', 9, 2 );

to restructure the categories:

Assign parent category to all posts that are already assigned to child category