Conditional that checks if a current category has any subcategory with posts

Please set hide_empty to true which will fetch only categories which is assigned to post.

$term = get_queried_object();

$children = get_terms( 'category', array(
'parent' => $term->term_id,
'hide_empty' => true
) );

error code: 523