How to target all woocommerce categories that don’t have any subcategories in them?

You can use the woocommerce_products_will_display(). This function returns true if the current shop page is going to display products. This will be the case if your shop pages are set to display products or subcategories and products, but it will be false if the shop pages are set to display subcategories only, and the current category has subcategories.

if ( woocommerce_products_will_display() ) {
    // Products are showing.
} else {
    // Products are not showing.
}

The woocommerce_get_loop_display_mode() is similar, but can let you know whether subcategories are also displaying:

switch ( woocommerce_get_loop_display_mode() ) {
    case 'products':
        // Products are displaying.
        break;
    case 'subcategories':
        // Subcategories are displaying.
        break;
    case 'both':
        // Products and subcategories are displaying.
        break;
}