Guy is walking down the street, minding his own business. There's a warrant out for the guy he's with. I guess proximity to someone with a warrant is enough to justify a search.
https://www.mass.gov/files/documents/2018/02/09/16P1580.pdf
The issue before us is whether a police officer was justified in stopping the defendant , who was walking with a man for whom the officer had an active arrest warrant involving the use of a firearm in the commission of a violent felony. Concluding that under these narrow circumstances police and public safety concerns outweighed the minimal intrusion on the defendant's liberty for the time it took for police to take control of the scene and effectuate the other individual's arrest, we affirm.
https://www.mass.gov/files/documents/2018/02/09/16P1580.pdf