You can first try the following comment query:
$comments = get_comments(
[
'post_type' => 'projects',
'post_status' => 'publish',
'type' => 'message',
'date_query' => [
[
'before' => '5 days ago midnight',
'inclusive' => true,
]
],
'meta_query' => [
[
'key' => 'foo', // <-- Adjust to your needs!
'value' => 'bar' // <-- Adjust to your needs!
]
]
]
);
and then collect the post ids with:
$post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );
You might want to consider to restrict the number of queried comments with the number
attribute.
Then you could e.g. use it with:
$query = new WP_Query( [ 'post__in' => $post_ids, ... ] );
for a non-empty $post_ids
array.