Hold for editions feedback and questions

I’m trying to use Run Code to store historic sales data in a metafield. In essence the javascript iterates through the line item products, checks if that metafield exists, updates it if it does, and creates an array of the product ids and the new metafield json data. I return it at the end of the function:
return {
metafieldsToUpdate: metafieldsToUpdate,
updatesNeeded: count
};
then in the output i have:
type Output {
updatesNeeded: Int!
metafieldsToUpdate: [metafieldsToUpdate]!
}

type metafieldsToUpdate {
productId: ID!

}
However when I check the logs of the failed run it shows me this:
“return_value”: {
“metafieldsToUpdate”: [
{},
{},
{},
{}
]
however if I console.log that variable right before the return, I see the output I expect:
“[[{"productId":"gid://shopify/Product/7009468874921"},{"productId":"gid://shopify/Product/3936949534743"},{"productId":"gid://shopify/Product/8524681085097"},{"productId":"gid://shopify/Product/7854781235369"}]]”
I just don’t know where I’m going wrong here