Sherlock went to John before he went to Mary

In Morocco, it is revealed that Sherlock had bugged the AGRA memory stick and that it had been John’s idea, but Mary escapes with the memory stick immediately after Sherlock first shows it to her, and Sherlock certainly isn’t able to bug it while he’s unconscious or talk to John about it. This means that after he finds the memory stick, Sherlock goes to John and tells him what he’s found and John is suspicious enough of what Mary might do when she finds out that he has the idea to bug it. The two of them came up with this plan together, and when I first watched TST I was upset at how little Sherlock and John had been communicating, but it turns out they were in it together all along.