Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Hold Requests: Add Hold/UnHold MenuItem and API call #28103

Closed
robertjchen opened this issue Sep 25, 2023 · 3 comments
Closed

[WIP] Hold Requests: Add Hold/UnHold MenuItem and API call #28103

robertjchen opened this issue Sep 25, 2023 · 3 comments
Assignees
Labels
Monthly KSv2 NewFeature Something to build that is a new item. Task

Comments

@robertjchen
Copy link
Contributor

This task is reserved for agency.

Overflow Menu

In <MoneyRequestHeader, add a new Hold entry to threeDotsMenuItems with a clock icon.

When selected it should called the locally defined method holdMoneyRequest()

Lastly, this Hold menu item will only be conditionally rendered based on ReportUtils.isOnHold(moneyRequestReport) If so, render the 'Hold' text for the popover menu option, or 'Unhold' otherwise.

Holding a request (member & admin)

When holdMoneyRequest() is called after the user taps Hold in the Overflow Menu.

In the function, we'll check if ReportUtils.isOnHold(moneyRequestReport) evaluates to true where we will Navigation.navigate(ROUTES.getMoneyRequestHoldRoute( … )) to an interstitial for the user to provide a reason for the hold request.

Reason Interstitial

Under src/pages/iou, create a new HoldReasonPage where we'll capture the user-provided reasoning for the hold.

The structure of the page should should resemble the following:

<ScreenWrapper>
            <HeaderWithBackButton>
<Form submitButtonText={translate('iou.holdRequest'')}>
<Text> 
<TextInput>
…
  • The key implementation details here to make note of are that:
  • The page is auto-focused when navigating to the page.
  • That error message is displayed after submission of an empty field for the reason.

When the user confirms the reason, we Navigate back to the MoneyRequestPage, passing the user-provided reason.

Back on MoneyRequestPage, fire off an API call with the following parameters:

API.write( 'HoldRequest',
{
	transactionID, // the money request being held
	comment        // the reason given for the hold
...
}

Onyx Data Response

Optimistic

{
    onyxMethod: Onyx.METHOD.MERGE,
    key: ONYXKEYS.COLLECTION.TRANSACTION,
    value: {
        [currentTransactionID]: {
            memo: {
                held: {
                    accountID: '<accountID>',
                    date: DateUtils.getDBTime(),
                    comment: ''
               },
            },
        },
    },
},

Success
API Onyx data response

Failure

{
    onyxMethod: Onyx.METHOD.MERGE,
    key: ONYXKEYS.COLLECTION.TRANSACTION,
    value: {
        [currentTransactionID]: {
            memo: {
                held: null
            },
        },
    },
},

Unholding a request (member & admin)

When the Unhold menu item is tapped, holdMoneyRequest() is called.

In the function, we'll check if ReportUtils.isOnHold(moneyRequestReport) evaluates to false. Unlike holding a request, no reason is required, so we can immediately fire off an API call like the following:

API.write( 'UnholdRequest',
{
	transactionID, // the money request being held
...
}

Onyx Data Response

Optimistic

{
    onyxMethod: Onyx.METHOD.MERGE,
    key: ONYXKEYS.COLLECTION.TRANSACTION,
    value: {
        [currentTransactionID]: {
            memo: {
                held: null
            },
        },
    },
},

Success

{
    onyxMethod: Onyx.METHOD.MERGE,
    key: ONYXKEYS.COLLECTION.TRANSACTION,
    value: {
        [currentTransactionID]: {
            memo: {
                held: null,
            },
        },
    },
},

Failure

Onyx data response
@robertjchen robertjchen added Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 25, 2023
@robertjchen robertjchen self-assigned this Sep 25, 2023
@melvin-bot

This comment was marked as outdated.

@robertjchen robertjchen added Task NewFeature Something to build that is a new item. and removed Daily KSv2 Bug Something is broken. Auto assigns a BugZero manager. labels Sep 25, 2023
@melvin-bot melvin-bot bot added the Weekly KSv2 label Sep 25, 2023
@robertjchen robertjchen added the Daily KSv2 label Sep 25, 2023
@melvin-bot melvin-bot bot removed the Daily KSv2 label Sep 25, 2023
@Expensify Expensify deleted a comment from melvin-bot bot Sep 25, 2023
@Expensify Expensify deleted a comment from melvin-bot bot Sep 25, 2023
@robertjchen robertjchen changed the title [WIP] Hold Requests: Add Hold/UnHold Button and API call [WIP] Hold Requests: Add Hold/UnHold MenuItem and API call Sep 25, 2023
@melvin-bot melvin-bot bot added the Overdue label Oct 3, 2023
@melvin-bot melvin-bot bot added Monthly KSv2 and removed Weekly KSv2 labels Oct 18, 2023
@melvin-bot
Copy link

melvin-bot bot commented Oct 18, 2023

This issue has not been updated in over 15 days. @robertjchen eroding to Monthly issue.

P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!

@melvin-bot melvin-bot bot removed the Overdue label Oct 18, 2023
@melvin-bot melvin-bot bot added the Overdue label Nov 20, 2023
@robertjchen
Copy link
Contributor Author

Succeeded by #31300

@melvin-bot melvin-bot bot removed the Overdue label Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Monthly KSv2 NewFeature Something to build that is a new item. Task
Projects
None yet
Development

No branches or pull requests

2 participants