Embedded Applescript permission to update title of photo?

I'm trying to update the title of any media imported into Apple Photos to be a certain text string (which includes data that i can use to find the media item later). The AppleScript i wrote works in Script Editor. But it doesn't work when run via Hazel. No errors, just doesn’t actually update the title. Any idea why?
tell application "Photos"
launch
set foundItems to (media items whose filename is the name of theFile)
if the number of items in foundItems is greater than 0 then
set firstItem to the first item in foundItems
set the name of firstItem to the name of theFile
end if
end tell
I've used just the name of theFIle for now (but it will be a more unique string in practice)
tell application "Photos"
launch
set foundItems to (media items whose filename is the name of theFile)
if the number of items in foundItems is greater than 0 then
set firstItem to the first item in foundItems
set the name of firstItem to the name of theFile
end if
end tell
I've used just the name of theFIle for now (but it will be a more unique string in practice)