In Bereishit 42:19-20 Yosef says that by allowing one of them to be imprisoned and the rest returning and bringing back their other brother, this would prove that they are not spies.
I've read various Mikra'ot Gedolot commentaries, and I understand the Midrash that says that they entered via separate gates to look for Yosef. Because they didn't all enter in one gate, Yosef accused them of being spies. So, I understand how he arrives at his accusation.
But, in reading the commentaries, I'm not seeing anything that explains the connection of bringing down their other brother absolves them of the spy accusation.
In light of @robev's comment, I'm adding some extra clarification of a nuance I see in various verses. I originally concentrated on Bereishit 42:16 where Yosef says that he will test to see if what the brothers said - namely, that they were all brothers of the same family and all they did was come to buy food - was true. If they couldn't do that, then they were spies.
However, when the brothers relay the story to Ya'akov in verse 34 they say that Yosef said, "In this way I will know that you are not spies, but you are honest people."
There's a bit of a nuance I see in this second verse. To me, it implies not just proving that they were correct in their claim, but they also had to prove that Yosef's claim that they were spies was wrong.
Thus, in providing defense to the accusation, they may have had to do both according to Yosef's demand, (in most U.S. court cases, (and perhaps, in halacha, as well) as I understand, when the defense provides proof that his claim is right, it doesn't necessarily counter the accusation, and it may not be a defense at all.) or, to my original claim, that the proof of their original claim that they were brothers of one family contradicted Yosef's claim.