If the old junction box hanger is too wimpy to hang a fan onto, and there is no access from above, you can get a fan brace that will fit right up through the old hole.
It adjusts to gradually widen until it digs in to the joists on both sides.
Then a new heavy junction box goes onto it from below.
It takes more work if your wiring is in solid conduit.
You need to be able to take apart and remove the existing junction box, and get it out of the way, and remove the old box hanger.
Even if you need to widen the hole here and there to do that, you can add a ceiling fan medallion over it, which is just a fancy trim ring of various styles that hides all that.
Sometimes you can make a small access hole next to the junction box, and sneak in some wood to help support the old box.
Then just do a crude drywall patch, and a ceiling medallion makes it look great.