I got it to work by setting the primary color attributes.
Here is the updated code:
Mesh->EnableVertexNormals(FVector3f());
Mesh->EnableVertexColors(FVector4f());
Mesh->EnableAttributes();
Mesh->Attributes()->EnablePrimaryColors();
const auto ColorOverlay = Mesh->Attributes()->PrimaryColors();
for (int i = 0; i < MeshData.Vertices.Num(); i++)
{
int Id = Mesh->AppendVertex(MeshData.Vertices[i]);
Indices.Add(Id);
Mesh->SetVertexNormal(Id, FVector3f(MeshData.Normals[i]));
Mesh->SetVertexColor(Id, FVector4f(MeshData.Colors[i]));
ColorOverlay->AppendElement(FVector4f(MeshData.Colors[i]));
}
for (int i = 0; i < MeshData.Triangles.Num(); i += 3)
{
const int T0 = Indices[MeshData.Triangles[i]];
const int T1 = Indices[MeshData.Triangles[i + 1]];
const int T2 = Indices[MeshData.Triangles[i + 2]];
const int Id = Mesh->AppendTriangle(T0, T1, T2);
ColorOverlay->SetTriangle(Id, UE::Geometry::FIndex3i(T0, T1, T2));
}
MeshComponent->NotifyMeshUpdated();