Assume Hewitt wins in two sets, that's the best he can do:
Match W/L 2/1
Sets W/L 4/3
If Costa wins he will also have a 2/1 match W/L record and a 5/3 or 5/4 sets W/L record, depending on whether hey wins in straight sets or not.
The first scenario will see Costa qualify because of a +2 W/L sets record compared to +1 for Hewitt.
If the rules I have are right even a three set win would put Costa through, because with the 5/4 set W/L record, he will still have won more sets than Hewitt and qualify.
Hewitt has to hope for Moya beating Costa