Subdivision Modifier renames mesh data name, Match By Name in Substance Painter won't work

This is more of a PSA post and to saving others wasting hours looking through their extensions looking for bugs like I did (actually found some other unrelated bugs so maybe I should not complain). I’ve also added a bug report here https://projects.blender.org/blender/blender/issues/161064

Issue

When exporting an object that has (only a) subdivision modifier on it, it renames the data mesh name to Mesh. This is problematic for programs such as Substance Painter that tries to match meshes based on their names in the texture baking process. Adding another modifier to the stack like Smooth By Angle or Weighted Normals fixes the issue.

This affect both GLTF and FBX export.

So essentially the reason that your high poly mesh has names like “Mesh.128” in Substance Painter is because the object you exported only had a single Subdivision modifier on it, and there is a bug which causes it to rename the mesh data name to “Mesh”, and since Blender does not allow for same names to be used, it adds the .xxx incremental suffix.

Current workaround

Adding certain modifiers to the object fixes the issue. For instance adding a Smooth By Angle or a Weighted Normals modifier further down the stack fixes the issue. The mesh data name will keep its name after export. Note that is must be a modifier in the stack. Simply right clicking and Shade Smooth’ing it will not fix the issue.