Incorrect last activity timings on admin users page

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

To minimize the license usage the user is trying to deactivate some users from the instance. However, when they sort active users with "Oldest recent activity" they are not able to deactivate some of those users.

Screenshot_2021-07-06_at_8.09.29_PM

Screenshot_2021-07-06_at_8.07.30_PM

Where in user with the close activity dates is showing the option to deactivate.

Screenshot_2021-07-06_at_8.26.34_PM

Console is also showing same information for active data

irb(main):019:0> user.last_active_at
=> Thu, 24 Jun 2021 20:13:05 UTC +00:00
# This is obviously less than 90 days. There is a 4 month difference.

# User is listed for 1 Apr, 2021 and can be deactivated. Gitlab-rails console now concurs:
irb(main):021:0> user.last_active_at
=> Thu, 01 Apr 2021 09:15:36 UTC +00:00

Steps to reproduce

Go to yourdomain.com/admin/users and sort by last activity on and try deactivating some of the users.

What is the current bug behavior?

Based on the discussion with @manojmj he suggested that the "Last activity" column in the UI is showing the attribute user.last_activity_on. However, the attribute used to determine whether the user can be deactivated is user.last_active_at , which uses the logic [last_activity_on, last_sign_in].compact.max . So if the user has a sign-in within the last 90 days, but no activity - this can happen.

What is the expected correct behavior?

It should show the correct user activity data in the UI.

ZD: https://gitlab.zendesk.com/agent/tickets/221844

Edited by 🤖 GitLab Bot 🤖