How do I check if I can use the allowed_block_types filter?

You can check if the current theme supports Gutenberg blocks inside your function

function amb_allowed_block_types( $allowed_blocks ) {
    if(! current_theme_supports('wp-block-styles') ){
        return $allowed_blocks;
    }
    return [
        'core/paragraph',
        'core/image',
        'core/heading',
        'core/gallery',
...