I'm glad being a biochem nerd pays off sometimes. Glycogen depletion tends to lead to overall fatigue, so the leg cramp may well have been a manifestation of that. Or, if I recall correctly, you need ATP to persuade muscle to relax. A lack of sugar could certainly cause a cramp in that case...

You might want to keep something easily munchable at work if you plan on riding afterward. The other thing I'd say to do is to keep an emergency gel or two in your seatbag, preferably flavors you don't like so you're not tempted to dip into them unless it is an emergency. (Any flavor works for me because I don't like the texture of gels, so unless I didn't bring shot blocks...)