Facebook’s “hack-a-thons” are the stuff of geek legend. Every month or two, software engineers stay up all night to brainstorm new features and write code to create them.

Refrigerators are stocked with Red Bull. Chinese food is delivered. House music plays till morning — and so do some of Facebook Inc.’s in-house lawyers.