the prep 'when' in the perfect tense
- This room had been cleaned when the last tenant moved out.
- This room has been cleaned when the last tenant moved out.
Are the two sentences correct? If they are, I want to make sure that the difference between the sentences is cleaning the room before and after moving out.
Solution 1:
No, it isn't.
"Has been cleaned" implies that the cleaning was recent and the room is still clean.
"Had been cleaned" implies that the room was clean at the time being referred to (but could have got dirty since).
We would assume that the cleaning happened after the tenant left, but neither sentence says so definitively. You would have to say "had already been cleaned" if it happened before.
Solution 2:
The second is not idiomatic: we don't use the present perfect with an expressed point in time. We can use it with a period of time, including that expressed by "since", so:
This room has been cleaned since the last tenant moved out.
is fine.
Sentence 1 is fine: the past perfect does not have that restriction.
But, as Kate Bunting says, neither makes clear whether the cleaning was before or after the moving out. An alternative to her suggestion is
The room had been cleaned before the last tenant moved out.
The simple past "was cleaned" would also be possible here, the difference being on whether the speaker was choosing to put temporal focus on the moving out or not.