If your door won't line up square you should probably check the floor to shell attachment, especially right at the bottom of the door.
Water from a leak at the front can cause the fiberglass "tabbing" that attaches the shell to the wood floor to pull loose. It does not take enough water to have a rotted floor for this to happen, just enough to cause the top layer of plywood to come loose and the wall can shift.
Bottom of door spreads due to not being anchored. More work to fix but cheaper than a door. Now my front floor was really rotted so my job may well have been more than you would be looking at. Pictures are just to show you where and what to look for, along with how it was fixed.
Mine the problem was at the front under the couch, symptom was the door was wider at the bottom (hinges pointed down so to speak). I suppose the closet side could also become detached and cause the same effect. I had to pull the bottom front of the door back to square and re-fiberglass it to the floor.
Top picture in this set notice the new piece of plywood, that was rotted and loose allowing the bottom of the door to move. You can also see the same piece of plywood in the bottom picture (lower right corner) Frame does NOT reach the bottom edge of door, only that piece of plywood.
Below is how I rigged things up to only pull the bottom front of door frame back until it ran straight up and down.