I took a quick look at your script.
I do not know where the the displacement map come in,
The script seem the be replacing the object content of the current smart object layer.
That layer can have had all sort of photoshop functions associated with it and has an associated transform. All smart object layer have an associated transform and may have smart filters and filter mask as well.
I see no code to handle the smart object size and make the replacement object have the same size or insure the replacement object is the aspect ratio and size. Replacing a smart object content does not change the current layer's associated the transform that transformed the original object. If the replacement object is not the same size as the original object the transform may not work like your expecting.
An associated displacement map may come into play because of smart filters on the smart object layer. Displacement maps content are either for the layers content or for lower layers content to make the current layer to conform to lower layers contours.
In fact I create a four image picture package template that used a smart object for the image. Added CS2 for a file type that could be used to replace the image in your script and ran your script. It did pop up the ACR dialog if I select a raw file but it worked perfectly for my portrait cr2 files are the same size and aspect ratio. Ast the object.
And a jpeg was saved to my desktop.
When a different size landscape orianted portrait image is selected here is the result
Have you tried recording the replacing of the SO and applying of the Smart Filter with ScriptingListener.plugin?
Which version of Photoshop do you use anyway?
Because in my tests replacing the contents of a SO with Displace applied as a Smart Filter does not raise that dialog.