The correct option is B. Because of the Great Depression, these men needed to work. The infinitive phrase here that functions as a direct object is to work. The easiest way to find out what the direct object is is to ask the question - What? So, what did these men need? To work. Furthermore it could be replaced by the word "it".
A direct object is a noun phrase denoting a person or thing that is the recipient of the action of a transitive verb.