But if B bought it from the Bank "after" there were insufficient bids at the courthouse foreclosure auction. Banks normally list these properties for sale with a Realtor and the house is offered up to all of the "retail" buyers. With this type of sale you normally will receive a title insurance policy and all of the HOA fees and other liens will be fully paid at closing (as evidenced by an Estoppel Letter received by the title company doing the closing). So yes the buyer should have clear title and an insurance policy on the title.
I'm not an expert but I do believe the HOA is entitled to 1 year of back due HOA fees or 1% of the mortgage, whichever is less. Many HOAs attorneys will attempt to get a new owner to pay more their legal obligation and will actually foreclose upon the new owner--even when it may not be the "correct" amount owed. I've seen it happen... especially by certain well known sleazy HOA law firms.
If you bought it at the courthouse, you may have to hire an attorney to fight the HOA and determine exactly what you legally owe.
All the best,
Alma Rose Kee PA
Future Home Realty
Person B should have clear title or it would have had to be disclosed before closing.