Overtime hours are counted in two ways: either automatically (based on settings) or manually by the employee requesting an attendance record and having its work duration counted as overtime duration.
An employee can request to add overtime manually through Request to Add Attendance Record and activating the option This attendance record is for a past work that should be counted as overtime.

You can control how overtime durations are calculated in two ways:
Worktime settings,
There are two options in Worktime settings that control how overtime duration is calculated:
First option:

Turning on this option means that any work duration recorded within this work time range will be counted as overtime without logging any attendance offences.
Example: If Friday is counted as overtime for the employee, you can add work time, select Friday as its only workday, and turn on this option. Then, any recorded work time on Friday will be considered overtime.
Second option:
Enabling this option means that any work duration beyond than the duration that the worktime requires will count as overtime.
Example: If the official work hours are 8 hours, and an employee logs in 9 working hours during this worktime, 1 hour will be counted as overtime in the attendance record.
Example: If the official work duration for a flexible worktime is 8 hours. If the employee logs 9 work hours, then 1 hour will be counted as overtime.
There's an option in attendance settings that lets you count any work duration logged outside worktimes as overtime, and it's called Attendance outside worktime is overtime.

Example: If working days don't include Friday, and an employee works on Friday, the actual work duration will be counted as overtime in the attendance record.
Example: If the employee shows up at night while their set work time is in the morning, the actual work duration will be logged as overtime in the attendance record.
The reference is the check-in time. If the check-in time is within the worktime range, then worktime settings take priority, but if it’s outside that range, then the priority goes to attendance settings for the employee.
Example: If an employee is assigned to a work time 8:00 AM - 4:00 PM, and the allowed check-in/out window is 30 minutes. If the option Attendance outside worktime is overtime is enabled in the employee’s attendance settings, then if the employee checks in outside the worktime (for example, at 7:00 AM), the attendance settings will apply and any recorded working duration will be considered as overtime.