Copy Table 1 Row to Table 2 using the add feature from Table 1

In my project I am trying to copy a row from Table 1(table_Materials2) using an "ADD" action associated with the table. I want the user to be able to select a material and add it to the empty Table 2(table_newItemsAdd). I saw a post that explains what I want. Copy data from one table to another.
But when I follow the steps I am getting an error during runtime of the JS. [addLineItems: Cannot read properties of null (reading '0')]. I have attached my tables and code. Can you please take a look and see where I am going wrong with this code?

What is the default value of lineItem? You're selecting the first array element there but unless you explicitly set the default value to [null] you'll never reach the first part of the if statement.

I assume what's happening here is the default value is actually null and the second part of that block ends up trying to concat null, which JS doesn't like. Drop the [0] from the if condition and it should work fine.

That worked!! Thank you!