I’ve done a handful of tests using the script below. It’s been across a variety of storage providers (including of course iCloud), folder structure depths and file formats. Each has given me the expected filename in the last URL component.
Maybe you could have a quick test and see if that holds true for you too?
alMsg = new Alert();
alMsg.title = "First Received Filename";
alMsg.message = args.fileURLs;
//Copy URL to clipboard and display in an alert
Example result from iCloud (Keynote’s folder)
Example result from Working Copy.