I am writing a paper and I wrote, I think the main reason I tried was because of whom I was with. Should I have written who?

"whom" is correct.

Who is used as a subject.
Whom is used as an object.
"of" is a preposition... so whom is the object of the preposition.

Thanks!

Yes, in this sentence, "who" is the correct pronoun to use instead of "whom." The pronoun "who" is used when it functions as the subject of a sentence or clause, as in this case.

To determine whether to use "who" or "whom," you can consider the role of the pronoun in the sentence. If the pronoun is performing the action (subject), you should use "who." On the other hand, if the pronoun is receiving the action (object), you would use "whom."

To further understand this, you can identify the subject and the verb in the sentence. The subject is "I" and the verb is "was." The phrase "who/whom I was with" functions as the object of the preposition "because of." Since "who" is the pronoun performing the action (in this case, being with someone), it should be written as "who."

Therefore, you should write, "I think the main reason I tried was because of who I was with."