Skip to content

AMI-7: Require a reason when rejecting an expense - #4

Closed
aminbaa wants to merge 1 commit into
factory_pre_mergefrom
factory/AMI-7
Closed

aminbaa wants to merge 1 commit into
factory_pre_mergefrom
factory/AMI-7

Conversation

@aminbaa

@aminbaa aminbaa commented Nov 28, 2026

Copy link
Copy Markdown
Owner

Linear: https://linear.app/aminbaa/issue/AMI-7/require-a-reason-when-rejecting-an-expense

Factory decision: build

Make POST /expenses/{id}/reject require a 1–500 character reason, store it, return it when the expense is fetched, and return 422 when it is missing.

Plan: Add a nullable reject_reason column to the expenses table in app/db.py, with a small ALTER for existing databases because the schema uses CREATE IF NOT EXISTS.
In app/expenses.py add a RejectIn model with reason: str = Field(min_length=1, max_length=500). Make the reject endpoint take it as the body and have decide store it. Approve is unchanged.
Return the stored reason in the expense responses (the SELECT * rows already include it).
Update the existing reject test to send a reason. Add tests for a missing reason (422), an empty reason (422), a reason over 500 characters (422), and the stored reason showing up on GET. Update the README endpoint table.

Why:

  • The ticket is specific enough to implement: a required reason of 1 to 500 characters on POST /expenses/{id}/reject, stored, returned on fetch, and a 422 when missing.
  • It stays inside the expenses team's default ownership (* in CODEOWNERS). It does not touch app/auth.py or .github/, which are the platform-owned paths, as far as the ticket describes.
  • It does not involve amounts or currency conversion, and it does not touch personal_phone or work_phone, so the data rules are not triggered.
  • Required workflow still applies: make the change on a branch, open a PR, add tests for the new behaviour, and pass CI before merging.
  • Minor details can be settled by the most likely reading without asking: whitespace-only reasons should count as empty (422), and the 500-character limit is counted on the submitted string.
  • Condition: if implementing this turns out to need changes under app/auth.py or .github/, the decision changes to escalate, because those paths need platform-team review.
  • The acceptance criteria are specific and testable: required field, length 1–500, stored, returned on GET, 422 when missing.
  • FastAPI/pydantic already returns 422 for body validation failures, so no custom handling is needed.
  • The change touches only app/expenses.py, app/db.py, tests and README. None of these is under a CODEOWNERS-restricted path (app/auth.py, .github/).
  • The reason is free text from a manager, not personal data under docs/data.md, and there are no money rules involved.
  • Existing visibility rules in can_view already limit who can fetch an expense, so the owner (the employee) and their manager can see the reason.

Opened by ticket-factory. CI and review run on this PR; the factory lands it into factory_pre_merge when they pass.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@aminbaa

aminbaa commented Nov 28, 2026

Copy link
Copy Markdown
Owner Author

Could not land into factory_pre_merge (conflict). The factory will rebuild on top of it.

@aminbaa aminbaa closed this Nov 28, 2026
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.

1 participant