I am able to update status using this code In this image highlighted text is username of currently logged in user, when I changed status from dashboard it shows me name, but when I change status using code it won't show any name.
I want username should be display like in this screenshot:
Try this code
You can use the following hooked function to get the shop manager user name in the order note:
Code goes in function.php file of your active child theme (or active theme). Tested and works.
Related thread: Add the Shop Manager username to Woocommerce Admin Order notes