Every object from a list whose property is one in a list of object IDs

I am scripting Photos.app. I have a list of object IDs of type “media item”, and I need to get all the media items that match one of the given ids.

Basically, something like this:

set theIDs to {"6S%QjtwmQcK22i6EV7Yyow", "BM12SMwNTDK+yZnZrXUsOA"}
tell application "Photos"
	set theItems to every media item whose (theIDs contains id)
end

The above leads to the error “Can’t make {…} into type specifier”.

I also tried to convert the list to a string and then check if “id is contained by theString”, but that fails with the same error, too.

How to I accomplish in the most efficient (performance) way?

One solution I found was to go over the list of IDs and fetch the media items by their ids. This works because any object can be looked up by their ID directly. It would not work for any other property of such objects.

set theItems to {}
repeat with anID in theIDs
	set anItem to media item id anID
	set end of theItems to anItem
end repeat

Yeah I’ve attempted everything I could trying the same thing
Getting all iTunes library tracks who’s persistentID is in an array of persistentIDs.

Kept getting errors that were something like. “Can’t use grouping operator on SBElement array.
The “IN” predicate for AppleScript and ScriptingBridge seems to only work with strings.

I tried predicate with block. Which again can’t be used.
I finally found this post and it works and doesn’t seem to be too slow .
(My “in” list is never more than 250 Objects.

You create a compound OR predicate and use that to filter.
You have to translate it to AsOBJc but it will work (let me know if you need help translating it)

https://stackoverflow.com/questions/16759079/in-operator-with-nspredicate-and-sbelementarray

I made a simple repeat loop

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

set theIDs to {"89288F35-8BCC-49AF-BBDF-C5DF0AD19455/L0/001", "67AD9ECC-C484-468A-89E4-439A94F3CDF5/L0/001"}
set theItems to {}
tell application "Photos"
	repeat with anID in theIDs
		set end of theItems to media item id (contents of anID)
	end repeat
end tell

This should work pretty well depending on the number of IDs you have in “theIDs”.
How many on average do you normally have?