Undo applies to the model, not view
Undo/Redo operations are applied to the system model (data), not the view (search MVC for more).
There is never a guarantee that when the user performs the undo operation, the affected data will be in the view.
If you try Miro (or any other similar app), you can add a shape, scroll it out of view, undo, and it won't re-position you to where the shape used to be (doesn't really make sense because it isn't there).
Having said that, on some applications the editor does takes you back to where what you had used to be (like on an IDE, because the undo also tracks the position in the document).
Still undos can be "per document"
In and IDE, or a word processor, undos are per document, not for the whole app. So there is higher chance that changes will be in the view.
In your specific case, after the user has created a task, I guess it will show somewhere on the screen (a table maybe)? So if the user clicks undo, that record should disappear.
Undo is normally for recent actions
So what a user undo is normally in their memory.
Undo operations have a title
Undo operations carry a title, so an undo menu item should say "Undo add task".
For keyboard shortcut triggers, you can always show a toast.