diff --git a/modules/costs/app/models/time_entries/scopes/ongoing.rb b/modules/costs/app/models/time_entries/scopes/ongoing.rb index 4a52c40b0e0c..7ef8dc360f2e 100644 --- a/modules/costs/app/models/time_entries/scopes/ongoing.rb +++ b/modules/costs/app/models/time_entries/scopes/ongoing.rb @@ -37,7 +37,12 @@ def ongoing def visible_ongoing(user = User.current) TimeEntry - .where(work_package_id: WorkPackage.allowed_to(user, :log_own_time), user:, ongoing: true) + .where(work_package_id: visible_work_packages(user).select(:id), user:, ongoing: true) + end + + def visible_work_packages(user) + WorkPackage.allowed_to(user, :log_own_time).or( + WorkPackage.where(project_id: Project.allowed_to(User.current, :log_time))) end def not_ongoing