Custom Category widget

Original Code Sample Removed, updated based on new answer:

Honestly this doesn’t change too much, other than makes it a bit more succinct, and I’ll explain the major points of what I’ve done.

You reuse this code sample a lot:

<li class="cat-item"><a href="https://wordpress.stackexchange.com/questions/295287/<?php echo get_category_link($cat->term_id); ?>"><?php echo $cat->name; ?></a><span class="post_count"><?php echo " ($cat_posts->found_posts+$cat_probs->found_posts)"; ?></span>

Inline, this gets relatively hard to read, and if you need to change or add a class to this, it gets a bit more tedious. Since it’s repeated three times, you should probably turn it into a function, so at the start I’ve created a function called jjycjn_display_link() that takes the category object, as well as the objects returned by your posts query and probs query, and echo the output automatically, so now all you need to do is use:

<?php display_link( $cat, $cat_posts, $cat_probs ); ?>

Which is much easier to digest when reading a file like this.

Another thing you can do is assign variables inside an if statement. You don’t need to assign a variable and then check if it exists, you can do that in one statement. So your

$categories = get_categories( array('parent' => 0, 'hide_empty' => 0, 'orderby' => 'term_order' ) );
if( $categories ):

is functionally equivalent to

if( $categories = get_categories( array('parent' => 0, 'hide_empty' => 0, 'orderby' => 'term_order' ) ) ):

That will assign $categories to the return value of get_categories(), and if it returns a Truthy Value then it will continue into the statement.

You might even be able to skip assigning the variables like $cat_posts and just drop the WP_Query into the jjycjyn_display_link() function since you don’t use the assigned variable, but I’ve left it for readability and debugging purposes (easier to debug if you have assigned it to a variable)

Best of luck!

<?php
    function jjycjn_display_link( $cat, $posts, $probs ){
        echo '<a href="'. get_category_link($cat->term_id) .'">'. $cat->name .'</a><span class="post_count"> ('. $posts->found_posts + $probs->found_posts .')</span>';
    }
?>
<aside class="widget widget_categories">
<h3 class="widget-title"><span class="widget-title-tab">Categories</span></h3>  
    <?php if( $categories = get_categories( array('parent' => 0, 'hide_empty' => 0, 'orderby' => 'term_order' ) ) ):
        echo '<ul>';
        foreach($categories as $cat):
            $cat_posts = new WP_Query( array( 'cat' => $cat->term_id, 'post_type' => 'post' ) );
            $cat_probs = new WP_Query( array( 'cat' => $cat->term_id, 'post_type' => 'probsoln' ) ); ?>
            <li class="cat-item"><?php jjycjn_display_link( $cat, $cat_posts, $cat_probs ); ?>
            <?php if( $sub_categories = get_categories( array('parent' => $cat->term_id, 'hide_empty' => 0, 'orderby' => 'term_order' ) ) ):
                echo '<ul class="children">';
                foreach($sub_categories as $sub_cat):
                    $sub_cat_posts = new WP_Query( array( 'cat' => $sub_cat->term_id, 'post_type' => 'post' ) );
                    $sub_cat_probs = new WP_Query( array( 'cat' => $sub_cat->term_id, 'post_type' => 'probsoln' ) ); ?>
                    <li class="cat-item"><?php jjycjn_display_link( $sub_cat, $sub_cat_posts, $sub_cat_probs ); ?>
                    <?php if( $sub_sub_categories = get_categories( array('parent' => $sub_cat->term_id, 'hide_empty' => 0, 'orderby' => 'term_order' ) ) ):
                        echo '<ul class="children">';
                        foreach ($sub_sub_categories as $sub_sub_cat):
                            $sub_sub_cat_posts = new WP_Query( array ( 'cat' => $sub_sub_cat->term_id, 'post_type' => 'post' ) );
                            $sub_sub_cat_probs = new WP_Query( array ( 'cat' => $sub_sub_cat->term_id, 'post_type' => 'probsoln' ) ); ?>
                            <li class="cat-item"><?php jjycjn_display_link( $sub_sub_cat, $sub_sub_cat_posts, $sub_sub_cat_probs ); ?>
                        <?php endforeach;
                        echo '</ul>';     
                        endif;
                    echo '</li>';     
                endforeach;
                echo '</ul>';   
                endif;
            echo '</li>';
        endforeach;
        echo '</ul>';
    endif; ?>
</aside>