We can simplify this quite a bit. At a high level, note that all you are doing is:
Converting each digit of the input to an array of possible neighbors.
Now you have an array of neighbor arrays.
The answer is simply the cartesian cross product of those neighbor arrays.
Turn the into back into strings.
The cartesian cross-product is a simple ...