Below is the complete code simplified for the question.
ids_to_check returns a list of ids. For my testing, I used a list of 13 random strings.
ids_to_check