Ensure access_level is present before comparison

What does this MR do and why?

This commit addresses an ArgumentError exception in Sentry caused by comparing an Integer with nil in the Member#higher_access_level_than_group validation:

ArgumentError
comparison of Integer with nil failed (ArgumentError)

    if highest_group_member && highest_group_member.access_level > access_level
                                                                   ^^^^^^^^^^^^

The validation assumes access_level is present, but this isn't guaranteed. Although we have an access_level_inclusion validation to ensure access_level is not nil, the order of validations in Rails is not predetermined.

To resolve this, we modify the validation to work even when some attributes are nil, ensuring robustness regardless of validation order.

References

Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

Run the newly added specs on the master branch.

Related to #507270 (closed)

Edited by Abdul Wadood

Merge request reports

Loading