Debug data hook

Can anyone help with what is wrong with this data hook? Looking to beforeInsert search by owner to update the dataset instead of adding in a new entry every time the owner submits to the data set title Module Completion (see attached screenshot). Any guidance is appreciated thank you!

What is the issue you are facing?

When a user submits to the data set, it is entered as a new set of data, instead of updating the owners previous submission. I had someone help me write the code to make it update the data set instead of insert, but the problem is still happening.

Why are you performing an insert? If you want to update a record, you can either use update or save and you won’t need a hook.

I didn’t realize this was an option! Did a lot of research and seems everyone was using hooks to make this happen. Could you possible help me with how to edit the code to reflect an update instead of the insert?