[server] Introduce getValidThreads function
Summary: In my next diff, I need valid threads from membership table, but also I want to have role for them. checkThreads handles everything I need, but maps rows to threadID - I don't want to do this at this point, so I added getValidThreads function, which will handle getting data from database, checking if thread is valid and filtering. checkThreads will call it, and map result, getting the same result as before
Test Plan: Flow, check if nothing changed in checkThreads result
Reviewers: palys-swm, ashoat
Reviewed By: palys-swm, ashoat
Subscribers: ashoat, palys-swm, Adrian, atul
Differential Revision: https://phabricator.ashoat.com/D1070