OS X Catalina, mail rule to run AppleScript from Application Script

Hi, I’ve got the following script to set up a new mail rule to run an applescript:


set applicationScriptsFile to (path to library folder from user domain as text) & "Application Scripts:com.apple.mail:test.scpt"
tell application "Mail"
	set myrule to make new rule at end of rules with properties {name:"test", all conditions must be met:true, delete message:true, run script:applicationScriptsFile, enabled:true}
	tell myrule
		make new rule condition at end of rule conditions with properties {expression:"test subject", rule type:subject header, qualifier:equal to value}
	end tell
end tell

the script runs, but when I check the rules in Mail.app, my script is not selected, as the SyncedRules.plist file contains the full path to the .scpt script. When the rule is set up manually from the application, with the correct script selected, the SyncedRules.plist file only contains the file scpt filename, as the system always picks it up from the Application Scripts folder by default.

Changing my AppleScript above to only be ‘test.scpt’ throws me an AppleEvent handler failed error. Any ideas what I’m doing wrong?