This happens quite a bit. Your bike falls over on the drive side, your wheel spokes eat your derailleur, or you simply knock it while handling it somehow. Whatever the case, you’ll end up with a non working drive train as your derailleur wont be planar with the rest of the chainline.

This is how I usually fix it. There are probably better and more clever ways out there but given what tools I have this is how I do it. First i use a small vise to clamp the dropout as such. I want the dropout to be fixed as I bend the hanger back. Next find an old derailleur preferable with a 6mm mounting bolt Allen hole.

Next take a 6mm Allen key and extend it somehow for more leverage. Insert it into the derailleur mount bolt and bend the hanger back to where it should be. Use the derailleur to gauge when the hanger is back to being co-planar with the rest of the driveline. Go slowly and be careful not to exert too much force, one can easily rip the hanger off.

Straight again! Surely it wont be perfect right away but once the actual derailleur is installed one can make small adjustments using the same method.