Pack the carpet riser out with underlay
Remove the carpet grip and add a thin lath.
Refit the gripper, or renew.
Fix carpet
Doesn’t matter if gap is uneven you cover it all as suggested.Only if life is that simple! The gap only appears on the right side. What I will do is use metal washers as shims and thread these through the fixing nails or replacement screws.