"Given that they passed the test" says we're only considering the 21 students who passed the test.
There were 9 students who didn't pass the test and 7 of those didn't complete the HW. This means that 2 students who did the HW didn't pass the test.
Since 20 students completed the HW and 2 didn't pass the test, 18 students completed the HW and passed the test.
18/21 = 6/7 or 85.71%
Your probability is 85.71%.