### Godot version

v4.1.rc1.official [1f9e540f1]

### System information

Windows 10

### Issue description

Attempting to reorder the children of a TabContainer results in an unintended ordering and incorrect undo states.

Also happens in v4.0.3.stable.official [5222a99f5].

https://github.com/godotengine/godot/assets/3820082/2c2458e3-88ad-46d9-8a04-f289a049984a



### Steps to reproduce

1. Add a new TabContainer
2. Add a few children to it
3. Drag and drop to erroneously reorder them
4. Attempt to undo the change

### Minimal reproduction project

N/A
for (int ni = 0; ni < p_nodes.size(); ni++) {
		
		Node *node = p_nodes[ni];
		fill_path_renames(node, new_parent, &path_renames);
		former_names.push_back(node->get_name());
		List<Node *> owned;
		node->get_owned_by(node->get_owner(), &owned);
		Array owners;
		for (Node *E : owned) {
			owners.push_back(E);
		}
		bool same_parent = new_parent == node->get_parent();
		if (same_parent && node->get_index() < p_position_in_parent + ni) {
			inc--; 
		}
		if (!same_parent) {
			undo_redo->add_do_method(node->get_parent(), "remove_child", node);
			undo_redo->add_do_method(new_parent, "add_child", node, true);
		}
		int new_position_in_parent = p_position_in_parent == -1 ? -1 : p_position_in_parent + inc;
		if (new_position_in_parent >= 0 || same_parent) {
			undo_redo->add_do_method(new_parent, "move_child", node, new_position_in_parent);
		}
		EditorDebuggerNode *ed = EditorDebuggerNode::get_singleton();
		String old_name = former_names[ni];
		String new_name = new_parent->validate_child_name(node);
		
		if (old_name.casecmp_to(new_name) != 0) {
			
			HashMap<Node *, NodePath>::Iterator found_path = path_renames.find(node);