This issue only applied to layered actions. The issue was that the `restore_channel_group_invariants()` method was being called too early in the remove fcurve function, and thus fcurves' group pointers could end up inconsistent with the membership specified in the groups. This commit fixes the issue by moving the call to `restore_channel_group_invariants()` to the end of the function, where it belongs. Pull Request: https://projects.blender.org/blender/blender/pulls/127075