Skip to content

Allow TMs to approve timesheet entries - #62

Merged
vas3a merged 2 commits into
developfrom
PM-6438_get-managers-update-access
Sep 28, 2026
Merged

vas3a merged 2 commits into
developfrom
PM-6438_get-managers-update-access

Conversation

@vas3a

@vas3a vas3a commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

This pull request updates timesheet approval permissions for Talent Managers (TM) and improves manager name hydration in timesheet responses. The main changes allow TMs to approve submitted timesheet entries (but not edit or submit them), update error messages and tests to reflect this, and ensure manager names are populated even if missing from the database.

Timesheet Approval Permissions

  • Talent Managers can now approve submitted timesheet entries, but cannot edit or submit entries. The code previously blocked TMs from approving; now only Members are blocked from approval. (src/timesheets/timesheets.service.ts, src/timesheets/timesheets.service.tsL503-R505)
  • Updated error messages and test assertions to clarify that TMs "cannot edit or submit entries" rather than "can view submitted timesheet entries only". (src/common/constants.ts, [1]; src/timesheets/timesheets.service.spec.ts, [2] [3] [4]
  • Adjusted tests to expect successful approval by TMs and verify correct database updates. (src/timesheets/timesheet-authorization.e2e.spec.ts, [1]; src/timesheets/timesheets.service.spec.ts, [2]

Manager Name Hydration

  • When a manager's name is missing from the database, the service now backfills it using the member service, ensuring all managers in the response have their names populated. (src/timesheets/timesheets.service.ts, [1] [2]
  • Added a unit test to verify that missing manager names are correctly backfilled. (src/timesheets/timesheets.service.spec.ts, src/timesheets/timesheets.service.spec.tsR170-R197)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The new manager-name hydration logic can leave blank names when the stored value is an empty/whitespace string, so the backfill behavior is currently incorrect for a real missing-name case.

Review effort: Lite
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

This PR adjusts timesheet authorization so Talent Managers (TMs) can approve submitted entries (while remaining unable to edit/submit), and improves timesheet view responses by hydrating manager display names when they’re missing in storage.

Changes:

  • Updated approval authorization to block only Members from approving timesheet entries (allowing TMs to approve).
  • Enhanced manager list hydration in timesheet views by backfilling missing manager names via the member service.
  • Updated error messaging and unit/e2e tests to reflect the new TM permissions and hydration behavior.
File Description
src/​timesheets/​timesheets.service.ts Allows TM approvals and adds manager-name backfill during timesheet view construction.
src/​timesheets/​timesheets.service.spec.ts Updates unit tests for TM behavior and adds a test for manager-name backfill.
src/​timesheets/​timesheet-authorization.e2e.spec.ts Updates e2e expectations to allow TM approval (201 instead of 403).
src/​common/​constants.ts Updates TM read-only error message to reflect “approve-only (no edit/submit)”.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +1347 to +1350
const hydratedManagers = managers.map((manager) => ({
...manager,
name: manager.name ?? nameByUserId.get(manager.userId) ?? null,
}));
Comment on lines +174 to +177
managerUserId: "2002",
managerHandle: "maryj",
managerName: null,
createdAt: utcDate("2026-09-01"),
@vas3a
vas3a merged commit 0783095 into develop Sep 28, 2026
4 checks passed
@vas3a
vas3a deleted the PM-6438_get-managers-update-access branch September 28, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants