Short answer: Both alternatives are grammatical. Between the two alternatives:
a) They didn't think I was gonna stick with it, and
b) They think I wasn't gonna stick with it,
a) is more natural and this syntactic phenomenon is called negative raising (or neg-raising).
I understand that from a learner's eye, it looks more natural to embed an original idea in the negative in a think-clause directly. However, it's more natural in English to raise the negation to the main clause when the main clause has a certain word (or technically, a predicate) such as: think, believe, want, seem, suppose, likely, and ought to.1
It might be counter-intuitive to learn that negative raising is the more natural/usual choice (if you want to dig deeper, search for marked-unmarked or markedness). But if you consider a little different sentence pair2, you may instantly see why:
c) I didn't claim anything.
d) I claim nothing.
Even though both sentences are semantically equivalent, I bet you can feel that d) is much stronger than c). (And thus, c) is the more natural/usual (i.e., unmarked) choice.)
1See more details at http://www2.let.uu.nl/uil-ots/lexicon/zoek.pl?lemma=negative+raising
2The sentence pair was taken from Negation in the History of English, p. 55
BONUS: This excerpt from Syntax and Metonymy also explains it quite well:
John doesn't think this novel is good.
is usually interpreted not as a statement about what John doesn't think but as a statement about what he does think. He does think this novel is not good. Similarly, the sentence
John doesn't want to leave early.
normally conveys John's positive desire not to leave early. This phenomenon has been referred to as Neg-raising (??, 19??) and as negative absorption (Klima, 1964).