Walking into a restroom stall and noticing the lock is broken is never a recipe for a good time. Sure, you could chance it and hope nobody tries to walk in, but there's an easy way to lock broken stall doors, and all you need is a hair tie. Just place one end of the hair tie on the lock and swing the other end through the hole the lock is supposed to slide into.
Next, slide the other end of the hair tie on the locking mechanism, and there you have it. You can now use the restroom comfortably, knowing there's no chance anyone will accidentally walk in.