Hey I came across the same issue today and this is what I ended up with and seemed to work.
function is_subcategory (){
$cat = get_query_var('cat');
$category = get_category($cat);
return ( $category->parent == '0' ) ? true : false;
}
which can be used in templates like any other conditional tag.
I was experiencing this same issue with my custom theme.
After troubleshooting, I narrowed it down to functions.php,
and for some reason if I prematurely closed the main php open tag ‘?>’
and reopened it, ‘<?php’ to include more functions, this is what seemed to be causing the problem.