If the HOA has filed a lien for unpaid dues (in excess of $1800 as you point out) it would indeed be cleared out by a superior lienholder (1st or 2nd mtg, for instance) foreclosing. The HOA could keep those in a superior position current and foreclose itself, but in today’s environment that probably wouldn’t make sense as I suppose most of the properties at issue may be under water.
If the HOA lien is wiped out, the HOA can still pursue payment from the former homeowner via legal action. Just because the HOA lien is wiped out doesn’t mean the obligation goes away.
Once the lender becomes the owner, they are obligated to pay HOA dues. If they do not, they property would once again be subject to an HOA lien ($1800 plus), HOA foreclosure and/or legal action against the lender for payment of dues.