Firstly, congrats on a beautifully written script, think you’ve done a great job commenting and formatting it and maintaining clarity throughout.
I can’t see the problem straight off, but for interest I’ve added before and after screenshots of the project, as the original project get’s nested on import, and may affect the script locations?
In the duplicated comp versions, the nested numbered comps get replaced with the image, rather than the image in the nested comp being replaced.
Regards the image duplication, I get 18 images imported: the script firstly loops through 2 rows of data in the TSV file. Then it loops through the 3 versions, before calling the importImagesForPrecomp<b style=”font-family: inherit; font-size: inherit; color: var(–darkreader-text–bb-body-text-color); –darkreader-inline-color: var(–darkreader-text–darkreader-text–bb-body-text-color);” data-darkreader-inline-color=””>() function, so you’ve got 6 calls to the function. Inside the function you loop through the images 3 times, so you get 18 images imported. I can see you’ve added logic to prevent duplicates being imported but I think you’re getting some false positives here.
I’ll let you know if I find anything else but you might find it useful to check the IF statement on line 67 and ensure it’s running correctly, as that’s the most obvious breakpoint. Test the output of the tests in the statement and ensure they’re always 100% what you expect.