# Feature OP-20705 - Add a filter and widget for the current user to ask "where I am"

Project: OpenProject
Status: new
URL: https://community.openproject.org/work_packages/OP-20705

## Planning

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Target versions | Wish List |
| Sprint |  |
| Backlog bucket |  |
| Votes | 2 |
| List |  |
| Roadmap |  |
| Relevance |  |

## OPEN POINTS / FEEDBACK

_No work packages_

## Features and Chunks

_No work packages_

## Bugs and other work packages

_No work packages_

## Technical Details

| Attribute | Value |
| --- | --- |
| Module | Modules and project features / Query and filter, Modules and project features / Project overview / Widget |
| Feature Flag |  |
| Requires doc change | Yes |
| Enterprise plan |  |

## Details

| Attribute | Value |
| --- | --- |
| Pull preview |  |
| Mockups |  |
| Accessibility | No |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Feature Lead |  |
| Developers |  |
| Designer |  |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Estimates and progress

| Attribute | Value |
| --- | --- |
| PD (min) |  |
| PD (max) |  |
| Work |  |
| Labor costs |  |

## Description

**As** a user who can query work packages  
**I want to** be able to list all the work packages that I am referenced in  
**so that** I can have a single view of my work

<br>

<img class="image_resized op-uc-image op-uc-image_inline" style="width:1232px;" src="/api/v3/attachments/926527/content">

## **Acceptance criteria**

  - A new work package filter, **"Where I am"**, is available on project work package lists, the global work package list and embedded tables, including My page widgets.

  - Its values are the roles I can hold on a work package. You can pick any of them:
    
      - Assignee, Accountable, Author and Watcher;
    
      - every user custom field, single or multi-value, that is used as a filter and is visible to me.

  - Inside a project, only the user custom fields active in that project are offered. On the global list, every user custom field visible to me is offered. Today core hides user custom field filters outside a project because their value picker loads every user ([<mention class="mention" data-id="33381" data-type="work_package" data-text="#33381">#33381</mention>](https://community.openproject.org/wp/33381)). That reason doesn't apply here, because the value is always the current user.

  - Operators:
    
      - **in** matches work packages where I hold any of the chosen roles (OR).
    
      - **not in** matches work packages where I hold none of them, including those where the chosen fields are empty.

  - A work package appears once, even if I hold several of the chosen roles.

  - A user custom field counts only where it is active on the work package (its type's form and project), exactly as the existing custom field filter decides. A value left behind after a type or project change doesn't count.

  - "Me" is always whoever is viewing, so one saved or shared view shows each person their own work.

  - Only the user is matched. Holding a role through a group doesn't count.

  - Role names are shown in the viewer's language. A renamed custom field shows its new name in saved views.

  - If a saved role is no longer available, it is ignored quietly instead of making the view fail or show nothing. That covers a custom field that has been deleted, is no longer a filter, is no longer active in the project, or isn't visible to the viewer. If every chosen role is unavailable, "in" matches nothing and "not in" matches everything.

  - A new My page widget, **"Work packages where I am involved"**: Where I am · in · Assignee, Accountable, Author, Watcher, plus Status · open. It has the same columns as the existing "assigned to me" and "watched by me" widgets. Users who may save views can change its roles in the widget's settings

## **Technical notes**

  - Patch was generated against **17.9.4.** It adds 40 files (+2,226 lines, no deletions), with specs and API docs included.

  - **Filter:**
    
      - `Queries::WorkPackages::Filter::InvolvesMeFilter`, registered in `app/models/queries/work_packages.rb` next to `WatcherFilter`. The API name is `involvesMe`, and the label is `query_fields.involves_me`.
    
      - Its type is `:involves_me_list`, mapped in `Queries::Filters::STRATEGIES` to `Strategies::WorkPackages::InvolvesMe::List`. This follows the SharedWithUser filter.
    
      - The strategy maps `=` and `!` to `Queries::Operators::WorkPackages::InvolvesMe::In`/`NotIn`, labelled "in" and "not in" (`label_operator_involves_me_in`/`_not_in`).
    
      - `available?` is false for anonymous users, whose "me" can never match.

  - **SQL:** `WHERE` only, no joins, so no duplicate rows.
    
      - Assignee, Accountable and Author use `(col IS NOT NULL AND col = me)`, which can use the column indexes.
    
      - Watcher uses an `EXISTS` on `watchers`. Unlike `WatcherFilter`, it needs no `view_work_package_watchers` check, because users can always see their own watches.
    
      - Each user custom field uses an uncorrelated `work_packages.id IN (SELECT customized_id FROM custom_values …)`, with the same joins as `CustomFieldContext#where_subselect_joins`. An `EXISTS` correlated through the project and type joins ran once per visible row when ORed with the other roles; the `IN` is hashed.
    
      - Every fragment is NULL-safe, so `not in` also matches empty fields.

  - **Values and roles that are no longer offered:**
    
      - `InvolvementRole` value objects (ids `assigned_to`, `responsible`, `author`, `watcher` and `cf_<id>`).
    
      - The `values` getter leaves out roles that are no longer offered. The strategy's `valid_values!` does nothing, so loading a saved query doesn't trim the stored roles. Otherwise a filter whose every role had been dropped would be emptied and discarded, and "in" would match every work package.

  - **API:**
    
      - `GET /api/v3/involvement_roles`
    
      - `GET /api/v3/involvement_roles/:id`
    
      - `GET /api/v3/workspaces/:id/involvement_roles`, mounted through `Workspaces::NestedApis` as categories is.
    
    The collections are never paginated (`count == total`), so the existing searchable multi-select picker narrows them in the browser. No Angular change is needed for the filter.
    
    Because of `NestedApis`, the per-workspace list is also served under `/api/v3/projects/:id/involvement_roles`. That path is left out of the API docs on purpose: core documents `/projects/` paths only as deprecated aliases, and this endpoint has no older clients.

  - **API docs:** OpenAPI paths, the `InvolvementRole` model, collection schemas, examples and an "Involvement roles" tag. `involves_me` is added to the work package filter list. Core's `spec/docs` checks validate the examples against their schemas.

  - **Schema:** `InvolvesMeFilterDependencyRepresenter`, whose cache key includes the project, because the roles offered differ by project.

  - **Saved values:** a view keeps the roles as chosen (`attributes_hash`). So someone who can't see one of the fields can star the view, or rename it through the API, without removing that role for everyone. Saving from the UI sends the filters as that person sees them, so it does remove the role.

  - **Widget:** `work_packages_involved`, registered in `MyPage::GridRegistration` with the existing static-table strategy and in `widgets.service.ts`. Its title is in `modules/grids/config/locales/js-en.yml`.

  - **Path helpers:** `involvement_roles`, `involvement_role`, `involvement_roles_by_workspace` and `involvement_roles_by_project`.

  - **Specs:**
    
      - the filter model spec, including one that checks it agrees with the custom field filter on which values are active, and anonymous users;
    
      - request specs for the roles API (including 403 without `view_work_packages`) and for queries using the filter, including loading a saved query after its roles are dropped;
    
      - the dependency representer spec, including a cache that differs by project;
    
      - role and collection representer specs;
    
      - the My page widget feature spec, and a "where I am" case in the work package filter feature spec;
    
      - cases in the path helper, filter dependency representer factory and My page grid specs.

  - **Against current** `**dev**`**:** most files apply as they are. `lib/api/v3/root.rb` (next to `LabelsAPI`) and the context names in `filter_dependency_representer_factory_spec.rb` need a small rebase.

  - **Related:** [<mention class="mention" data-id="24565" data-type="work_package" data-text="#24565">#24565</mention>](https://community.openproject.org/wp/24565), "Combine AND-filter with OR-filter". Its main example is this case. A general OR feature wouldn't make this filter redundant: this is one row instead of an OR group of four or five.

## **Permissions and visibility considerations**

  - **The filter:** anyone who can view work packages, wherever work package lists are available.

  - **User custom field roles:** only fields the viewer may see (`WorkPackageCustomField.visible`), so admin-only fields aren't offered to non-admins. Inside a project, only fields active there.

  - **The widget:** anyone using My page. Changing its roles needs permission to save views, as for the existing work package widgets.

  - **Anonymous users:** the filter is not available.

  - The per-project roles endpoint:
    
      - returns 404 for a project the user can't see;
    
      - returns 403 for a project they can see but can't view work packages in.

## **Translation considerations**

<figure class="table op-uc-figure_align-center op-uc-figure"><table class="op-uc-table"><tbody><tr class="op-uc-table--row"><td class="op-uc-table--cell"><p class="op-uc-p"><strong>Key</strong></p></td><td class="op-uc-table--cell"><p class="op-uc-p"><strong>English</strong></p></td><td class="op-uc-table--cell"><p class="op-uc-p"><strong>German suggestion</strong></p></td></tr><tr class="op-uc-table--row"><td class="op-uc-table--cell"><p class="op-uc-p">Filter name</p></td><td class="op-uc-table--cell"><p class="op-uc-p">Where I am</p></td><td class="op-uc-table--cell"><p class="op-uc-p">Wo ich beteiligt bin</p></td></tr><tr class="op-uc-table--row"><td class="op-uc-table--cell"><p class="op-uc-p">Operator =</p></td><td class="op-uc-table--cell"><p class="op-uc-p">in</p></td><td class="op-uc-table--cell"><p class="op-uc-p">in</p></td></tr><tr class="op-uc-table--row"><td class="op-uc-table--cell"><p class="op-uc-p">Operator !</p></td><td class="op-uc-table--cell"><p class="op-uc-p">not in</p></td><td class="op-uc-table--cell"><p class="op-uc-p">nicht in</p></td></tr><tr class="op-uc-table--row"><td class="op-uc-table--cell"><p class="op-uc-p">Widget title</p></td><td class="op-uc-table--cell"><p class="op-uc-p">Work packages where I am involved</p></td><td class="op-uc-table--cell"><p class="op-uc-p">Arbeitspakete, an denen ich beteiligt bin</p></td></tr></tbody></table></figure>

The role names reuse the existing translated attribute names (Assignee, Accountable, Author, Watcher). Custom field names are shown as entered.

## **Out of scope**

  - Matching through groups the user belongs to.

  - "Mentioned in" (comments or descriptions).

  - Choosing a user other than the current one.

  - A general AND/OR filter grouping ([<mention class="mention" data-id="24565" data-type="work_package" data-text="#24565">#24565</mention>](https://community.openproject.org/wp/24565)).

*Set the* **To be informed/consulted teams** *field to include all teams necessary to be informed of the changes.*
