For anyone dealing with the same issue, I just needed to change:
$choices[ $template_name ] = $template_name;
with:
$choices[ $template_filename ] = $template_name;
Consider a page template Homepage (page-home.php)
. This way the template name Homepage
will appear on the custom fields page but $rule['value']
will actually return page-home.php
and then we can compare this with get_page_template_slug( $post->post_parent )
.