I'm an analyst trying to understand a certain class of finitely presented groups (one example is below) so it's quite likely this question is naive but I hope it is at least intelligible. Given a finitely presented group $G$ with generators $g_1, \dots g_n$ and relations $R=\{r_1,\dots r_m\}$ one would like to solve the word problem in $G$; of course it is not solvable in general, but is solvable for certain classes of $G$. In particular there is Dehn's algorithm, which (as I understand it) runs like this: given a word $w$ in the generators, with length $|w|$, if one finds a subword $v$ of $w$ such that $vu^{-1}\in R$ and $|u|<|v|$ then replace $v$ by $u$ and continue. If no such word $v$ exists, stop. (The length-decreasing condition guarantees that the algorithm will halt.) Say Dehn's algorithm works if, whenever $w=e$ in $G$, then Dehn's algorithm successfully reduces $w$ to $e$. (One should probably have some symmetry conditions on the set of relators (that they be closed under cyclic permutations, etc.); for the purposes of this question assume whatever symmetry you need.)
It is known that Dehn's algorithm works for surface groups (this was Dehn's original result), and it has since been extended to groups satisfying some kinds of "small cancellation" conditions, word-hyperbolic groups, etc. My question is about the following modification of Dehn's algorithm and which, if any, groups for which it is known to work. The idea is simply to modify the original algorithm to allow substitutions $v\to u$ if $vu^{-1}\in R$ and $|u|\leq |v|$, rather than only $|u|<|v|$. (Since everything is finite, it seems clear enough that one can specify some particular method of searching through the word so that the algorithm still halts. That is, at each step first look for length-reducing substitutions; if there are none, look for length-preserving substitutions, there are only finitely many possible so one may enumerate the possibilities and specify some rule for picking one. After each length-preserving substitution, check again for length-reducing substitutions. If there is one, continue, if none of the possible length-preserving substitutions allow for a subsequent length-reducing substitution, halt.)
A motivating example is the following: consider the group $G$ on six generators $g_1, g_2, g_3, h_1, h_2, h_3$ and relations $$ R=\{ g_jh_kh_j^{-1}g_k^{-1}:j,k =1,2,3 \text{ distinct}\}; $$ enlarge $R$ to be closed under inverses and cyclic permutations. It is not hard to see that Dehn's algorithm fails in $G$: in particular one may verify that the word $$ w=h_2 h_1^{-1} h_3 h_2^{-1} h_1 h_3^{-1} $$ has the form $$ w=g_1^{-1} rstg_1 $$ with $r,s,t\in R$ so $w=e$ in $G$. But Dehn's algorithm does not reduce $w$ since all the relators have length 4, and no 3-letter subword of a relator appears in $w$ (a 3-letter subword of a relator must contain both $g$'s and $h$'s). However if we allow length-preserving substitutions such as $h_2h_3^{-1}\to g_2^{-1}g_3$ then the algorithm gets "unstuck": $$ h_2 h_1^{-1} h_3 h_2^{-1} h_1 h_3^{-1} \to h_2 h_1^{-1} g_2^{-1}g_3 h_1 h_3^{-1}\to g_1^{-1}g_3 h_1 h_3^{-1} \to e. $$ I suspect (but don't yet have a proof) that the modified Dehn's algorithm works for this group.
Question: are there known classes of groups (beyond those for which Dehn's algorithm works) for which the modified Dehn's algorithm (with substitutions $|u|=|v|$ allowed) solves the word problem?